This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use the new forum.
Home » plugins » User management plugins » more than one table for profile (sfGuard)
more than one table for profile (sfGuard) [message #57971] Tue, 05 August 2008 21:54 Go to next message
kurosaki  is currently offline kurosaki
Messages: 67
Registered: August 2008
Member
Hi, I have many tables for user profiles (student, teacher, coordinator) and each of these tables have already the FK to the users table (sfGuard), but I wonder about app.yml

They suggest this:

    all:
      sf_guard_plugin:
        profile_class:      sfGuardUserProfile
        profile_field_name: user_id



Where sfGuardUserProfile is the profile table, but what if I have 3 or 4 tables like I do?

Thanks.
Re: more than one table for profile (sfGuard) [message #58046 is a reply to message #57971 ] Wed, 06 August 2008 12:06 Go to previous messageGo to next message
halfer  is currently offline halfer
Messages: 9535
Registered: January 2006
Location: West Midlands, UK
Faithful Member
That's an interesting question. I've had a think and I reckon you could do it like this.

Have a general profile table, which is linked to sfGuardUser and is retrieved as normal using $this->getUser()->getProfile(). In that table, have a "type" column, which can be text or numeric as you see fit. This will determine whether the user is a student, a teacher, or a coordinator.

Then in your profile model, implement getUserObject() which gets the type and does a Propel select in the relevant table, returning either a Student, Teacher or Coordinator object (or null if nothing is found). Your code will obviously have to deal intelligently with the result, especially if the column signatures vary between these tables.

The minor downside with this approach is it adds in another select, but I don't think that's a major problem. You will be then able to do something like this:

$myObj = $this->getUser()->getProfile()->getUserObject();

Let us know how you get on, I'd be interested!


Remember Palestine
Re: more than one table for profile (sfGuard) [message #58093 is a reply to message #58046 ] Wed, 06 August 2008 19:09 Go to previous messageGo to next message
kurosaki  is currently offline kurosaki
Messages: 67
Registered: August 2008
Member
But in the general profile I have to mix all the profile columns and that could be a problem.

Since I'm understanding symfony, please explain me what does the app.yml file, what is it role?
Re: more than one table for profile (sfGuard) [message #58126 is a reply to message #57971 ] Wed, 06 August 2008 23:43 Go to previous messageGo to next message
halfer  is currently offline halfer
Messages: 9535
Registered: January 2006
Location: West Midlands, UK
Faithful Member
Quote:

But in the general profile I have to mix all the profile columns and that could be a problem.

No, you misunderstand me. The profile table as I have suggested would contain just two columns:

user_id (int)
user_type (string)

Then user_id would have a 1:1 mapping to the PK of Student (if user_type == 'student'), or to the PK of Teacher (if user_type == 'teacher') etc. On this basis you would have to work out a scheme to ensure that none of your user tables have conflicting primary keys.


Remember Palestine
Re: more than one table for profile (sfGuard) [message #59148 is a reply to message #58126 ] Wed, 20 August 2008 18:28 Go to previous message
kurosaki  is currently offline kurosaki
Messages: 67
Registered: August 2008
Member
Well I solve it somehow...

I have a user (profile) table that has a FK to sf_guard_user, also this profile table has a FK to a type_id where it can be student, teacher, etc.

And in my schema the needed tables have FK to the profile_id.
Previous Topic:sfGuard login form
Next Topic:[SOLVED] executepassword and overriding sfGuardAuth methods
Goto Forum:
  

powered by FUDforum - copyright ©2001-2004 FUD Forum Bulletin Board Software