Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Zend Framework: Zend_Db_Select - how to join custom subquery table?

$select->joinRight(array('i' => '(SELECT * FROM images ORDER BY image_id)'),'i.ad_id = '. $main .'.id',$imarray);

Like that doesn't work. Subquery getting inside quotes.

Like that:

RIGHT JOIN `(SELECT * FROM images ORDER BY image_id)` AS `i` ON i.ad_id = a.id

Thanks ;)

like image 948
Somebody Avatar asked Dec 04 '22 22:12

Somebody


1 Answers

Use

$select->joinRight(
    array('i' => new Zend_Db_Expr('(SELECT * FROM images ORDER BY image_id)')),
    'i.ad_id = '. $main .'.id',
    $imarray
);
like image 182
Tomáš Fejfar Avatar answered Jun 16 '23 22:06

Tomáš Fejfar