我正在尝试在用户和他的客户之间建立一对多的关系。当我这样设置模型时,我可以访问单个客户端:
class Model_User extends Model_Auth_User {
protected $_has_one = array(
'client' => array(
'model' => 'Client',
'foreign_key' => 'user_id')
);
[...]
但是当我尝试切换到 $_has_many 时:
class Model_User extends Model_Auth_User {
protected $_has_many = array(
'clients' => array(
'model' => 'Client',
'foreign_key' => 'user_id')
);
[...]
我收到以下错误:
Database_Exception [ 1103 ]: Incorrect table name '' [ SELECT COUNT(*) AS `records_found` FROM `` WHERE = '74' AND IN ('4') ]
想不通怎么回事。。