I have a model called User that has a Virtual field called full_name . When I access my User model in a find () query, I can set the conditions in my virtual field without any problems:
$user = $this->User->find('first', array( 'recursive' => -1, 'conditions' => array( 'User.full_name' => 'Bruce Thomas' ) ));
The above query will successfully return me the data for user Bruce Thomas. But the problem occurs when I try to use my User model through another model through Containable, for example:
$user = $this->MyOtherModel->find('first', array( 'contain' => array('User'), 'conditions' => array( 'MyOtherModel.id' => $my_other_model_id 'User.full_name' => 'Bruce Thomas' ) ));
(The example above assumes MyOtherModel has belongsTo relationship to my MyOtherModel model)
In the above query, the following error occurs:
Warning (512): SQL Error: 1054: Unknown column "User.full_name" in the "on" section [CORE \ cake \ libs \ model \ datasources \ dbo_source.php, line 681]
Any help on how I can do this, please? thank you
source share