我正在尝试在Zend中创建这个选择查询:
SELECT `receive`.`itemid`, `receive`.`room` FROM `tm_receive` AS `receive` LEFT JOIN `tm_rooms` ON tm_receive.room = tm_rooms.id
这是我的Zend_DB_Table选择对象:
$select = $this->select()
->from(array('receive' => 'tm_receive'),
array('itemid', 'room'))
->joinLeft(array('room' => 'tm_rooms'),
'receive.room = room.id');
但我收到此错误:Warning: Select query cannot join with another table in /var/www/myiartz/library/Zend/Db/Select.php on line 1350
我做错了什么?
答案 0 :(得分:2)
尝试使用:
$database = Zend_Db::factory( ...options... );
$database->select()->from(array('receive' => 'tm_receive'),
array('itemid', 'room'))
->joinLeft(array('room' => 'tm_rooms'),
'receive.room = room.id');
问题在于使用select()
时,结果将仅限于该表。