I'm working around a month with CakePHP 2.0, and today I found some problems with the hasMany relationships on find().
The relationships for model Usuario (user) is as follows:
$this->Usuario->bindModel(array(
'hasMany' => array(
'CambioCorreo' => array(
'className' => 'CambioCorreo',
'foreignKey' => 'id_usuario',
),
'Llave' => array(
'className' => 'Llave',
'foreignKey' => 'id_usuario',
))));
But when I try to use this find:
$u = $this->Usuario->find('all',array('conditions' => array('Llave.llave' => $llave,'Llave.id_tipo_llave' => 3,'Llave.fecha_creacion = CambioCorreo.fecha')));
, I got this:
Error: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'Llave.llave' in 'where clause'
Oddly enough, before doing the hasMany relationship, I did a hasOne as a mistake, and it worked pretty well. But now, I changed the bindModel from "hasOne" to "hasMany", and the SQL column error arises.
Anyone knows where I'm making the mistake?
Thanks in advance