我有这两个类:
class Client extends AppModel{
public $belongsTo = array(
'User',
'plans' => array(
'className' => 'Plan',
'foreignKey' => 'plans_id'
)
);
public $hasMany = array(
'Order'
);
}
}
class User extends AppModel{
public $belongsTo = array(
'Rol' => array(
'fields' => array('id', 'nombre')
)
);
public $hasOne = array(
'Client'
);
}
然而 cake 检索到这个:
'User' => array(
'password' => '*****',
'id' => '32',
'username' => 'test_admin',
'correo_electronico' => 'a@d.com',
'created' => '2013-06-09 19:58:18',
'modified' => '2013-06-09 19:58:18',
'esta_habilitado' => '1',
'rol_id' => '1'
),
'Rol' => array(
'id' => '1',
'nombre' => 'Administrador'
),
'Client' => array(
'id' => null,
'primer_nombre' => null,
'segundo_nombre' => null,
'primer_apellido' => null,
'segundo_apellido' => null,
'direccion' => null,
'diudad' => null,
'telefono' => null,
'rating' => null,
'created' => null,
'modified' => null,
'esta_habilitado' => null,
'plans_id' => null,
'user_id' => null
)
任何想法发生了什么,我检查了数据库中的外键,用户的 id 对应于客户端记录中的 user_id