mysql - CakePHP hasOne association returns array of empty fields for non-existant record -
have user , userprofile models. user model has hasone association userprofile. userprofile mysql table empty. when $this->user->find('all', array('contain' => array('userprofile'))) instead of empty userprofile array, expect, array populated empty fields correspond schema:
array ( [0] => array ( [user] => array ( [id] => 1 [firstname] => joe [surname] => bloggs [email] => katie.barnes@scotlandsdna.com [password] => $2a$10$re4r7axwqcxgkkcabuqmto6j.7p2ba1t2sleg93evsidpbggaexrs [enabled] => 1 [user_group_id] => 1 [created] => 2014-06-26 15:01:38 [modified] => 2014-06-26 15:01:38 ) [userprofile] => array ( [id] => [job_title] => [user_id] => [enabled] => [created] => [modified] => ) )
anyone seen , know how fix it?!
this correct behavior because hasone
association not optional. if want make optional, change hasmany
, ever create 1 record.
cake performing left join
user
userprofile
, query result produced null
values missing record. same result if executed sql in editor outside of cake.
Comments
Post a Comment