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

StackOverflow https://stackoverflow.com/questions/21586631

Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top