简体   繁体   中英

Zend Join Left Warning: Select query cannot join with another table in /var/www/myiartz/library/Zend/Db/Select.php

I am trying to create this select query in Zend:

SELECT `receive`.`itemid`, `receive`.`room` FROM `tm_receive` AS `receive` LEFT JOIN `tm_rooms` ON tm_receive.room = tm_rooms.id

This is my Zend_DB_Table Select Object:

$select = $this->select()
     ->from(array('receive' => 'tm_receive'),
            array('itemid', 'room'))
     ->joinLeft(array('room' => 'tm_rooms'),
            'receive.room = room.id');

But I'm getting this error: Warning: Select query cannot join with another table in /var/www/myiartz/library/Zend/Db/Select.php on line 1350

WHAT AM I DOING WRONG?

Try using this:

$database = Zend_Db::factory( ...options... );
$database->select()->from(array('receive' => 'tm_receive'),
        array('itemid', 'room'))
 ->joinLeft(array('room' => 'tm_rooms'),
        'receive.room = room.id');

The problem is when using select() , the results will be limited to that table only.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM