我有3张 table
用户 UserHasBasicTheme(联表user.id,user_theme.id) 用户主题
我想使用 findAll 方法通过给定的 user.id 获取所有 UserTheme
每个表都有自己的模型。
我尝试使用:
$this->UserTheme->bindModel(array('hasOne' => array('UserHasBasicTheme')));
$this->UserTheme->find('all', array(
'conditions' => array('UserHasBasicTheme.user_id' => $this->id)
));
但是下面的示例返回错误: 调用非对象上的成员函数bindModel()
我在用户 Controller 上调用它。
我想问一下,怎样才是正确的?
感谢您的建议。
最佳答案
您定义了 $uses 属性吗?
public $uses = array('UserTheme', 'User', 'UserHasBasicTheme');
对于 Controller ?
关于php - CakePHP -> 如何正确使用 findAll 和连接表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21166332/