I love You man!:D

I forgot to add   var $primaryKey = 'user_id'; in one class:D


On 18 Sie, 18:21, brian <bally.z...@gmail.com> wrote:
> Normally, with HABTM, you'd have these tables:
>
> users:
> id
> ...
>
> accounts:
> id
> ...
>
> accounts_users:
> account_id
> user_id
>
> I don't know if this is the reason for your trouble, but it's worth
> starting from what Cake expects and see if that resolves it.
>
> On Tue, Aug 18, 2009 at 8:09 AM, Ace<konradkrakow...@go2.pl> wrote:
>
> > I have my users in standard users table. There is also an account
> > table. Every user can have many accounts (account is let's say a group
> > of premissions, like a role) and every account can have many users so
> > the relation is HABTM (there is a linking table - account_user_assoc).
> > When the user is being logged in I want to know what roles does he
> > have, but Account object is empty. Can anyone tell me what do I do
> > wrong?
>
> > Cake generates query without even mentioning the Accounts table:
>
> > SELECT `User`.`user_id`, `User`.`contact_name`,
> > `User`.`email_address`, `User`.`username`, `User`.`password`,
> > `User`.`language`, `User`.`default_account_id`, `User`.`comments`,
> > `User`.`active`, `User`.`sso_user_id`, `User`.`date_created`,
> > `User`.`date_last_login`, `User`.`email_updated` FROM `ox2_users` AS
> > `User` WHERE `User`.`username` = 'root' AND `User`.`password` =
> > '7a89a595cfc6de85480202a143e37d2e' LIMIT 1
>
> > Results:
> > Array ( [User] => Array ( [user_id] => 1 [contact_name] =>
> > Administrator [email_address] => t...@test.pl [username] => root
> > [password] => 7a89a595cfc6de85480202a143e37d2e [language] => pl
> > [default_account_id] => 2 [comments] => [active] => 1 [sso_user_id] =>
> > [date_created] => 2009-08-13 18:45:50 [date_last_login] => 2009-08-17
> > 14:33:27 [email_updated] => 2009-08-13 18:45:50 ) [Account] => Array
> > ( ) )
>
> > User model code:
>
> > class User extends AppModel {
> >    var $name = 'User';
> >    var $recursive=2;
> >     var $hasAndBelongsToMany = array(
> >  'Account' =>
> >        array(
> >  'className' => 'Account',
> >  'joinTable' => 'account_user_assoc',
> >             'foreignKey' => 'user_id',
> >  'associationForeignKey' => 'account_id',
> > 'unique' => true
> >        )
> >    );
> >    function hashPasswords($data){
> >        $data['User']['password']=md5($data['User']['password']);
> >        return $data;
> >    }
>
> > }
>
> > Accounts model:
>
> > class Account extends AppModel {
> >    var $name = 'Account';
> >    var $primaryKey = 'account_id';
> > }
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to