0
我有以下型號:「NOT IN」 的Kohana ORM
class Model_User extends ORM {
protected $_primary_key = 'name';
protected $_has_many = array(
'repositories' => array(
'model' => 'repository',
'through' => 'repository_user',
),
);
}
class Model_Repository extends ORM {
protected $_primary_key = 'name';
protected $_has_many = array(
'users' => array(
'model' => 'user',
'through' => 'repository_user',
),
);
}
我用下面的代碼來獲取未連接到存儲庫的所有用戶:
$repository = ORM::factory('repository', $this->request->param('svn_name'));
$users = ORM::factory('user')->where('name', 'NOT IN', $repository->users->find_all()->as_array())
->find_all();
不幸的是我收到以下錯誤消息,如果沒有用戶連接到特定的資源庫:
Database_Exception [ 1064 ]: You have an error in your SQL syntax; check the manual
that corresponds to your MySQL server version for the right syntax to use near
')' at line 1 [ SELECT `user`.* FROM `users` AS `user` WHERE `name` NOT IN() ]
我怎樣才能解決這個問題,而無需使用如果只是使用Kohana-Methods?