我有兩個這是有關爲HABTM表:HABTM找到符合條件
- 組(ID,姓名)
- 流(ID,流)
連接表:
- groups_streams(id,group_id,stream_id)
HasOne集團還有另一種稱爲用戶的模式。
從用戶控制器我試圖得到與用戶組相關的流。
$streams = $this->User->Group->find('list', array('conditions' => array(`User.group_id` => 2)));
我這樣做,但我得到一個MySQL錯誤:
SQL Error: 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 '= 2' at line 1
SQL查詢:
SELECT `Group`.`id` FROM `groups` AS `Group` WHERE = 2
我很困惑:(