Zend Join Left警告:选择查询无法与/var/www/myiartz/library/Zend/Db/Select.php中的另一个表连接

时间:2014-02-05 19:26:37

标签: php mysql zend-framework join zend-db

我正在尝试在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

我做错了什么?

1 个答案:

答案 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()时,结果将仅限于该表。