Relational AR Fail :(

model user:

id PK, name

with relation:



public function relations()


{


	return array(


	'profiles'=>array(self::HAS_ONE, 'profile', 'user_id')


	);


}


model profile:

user_id, text

my code:



print user::model()->with('profiles')->findAll();


returns Invalid argument supplied for foreach() :(

Please kindly help.

Could you please provide complete error information?

what if you change

'profiles'=>array(self::HAS_ONE, 'profile', 'user_id')

to

'profiles'=>array(self::HAS_ONE, 'Profile', 'user_id')

and

print user::model()->with('profiles')->findAll();

to

print_r(User::model()->with('profiles')->findAll());

I'm wondering if it's a matter of upperCase/camelCase, altough I had the same error with a relation today and the solution was to rename my views/controllers/models to OLD_<name>  and rebuild them with the yiic 1.0.6 tool, which declares the relations from MySQL automatically in the generated models…

hope it helps!!  :)