No48
Новичок
Доброго времени суток.
Господа, подскажите, как правильно реализовать на Zend 1.11 такой запрос:
Вот такая реализация вызывает ошибку в методе joinLeft.
Заранее благодарю за помощь.
Господа, подскажите, как правильно реализовать на Zend 1.11 такой запрос:
SQL:
SELECT c.id, MAX(p.price) as max_price, MIN(p.price) as min_price
FROM catalog AS c
LEFT JOIN catalog_products AS p
ON p.parent = c.id
WHERE (c.url_key = 'url')
AND (c.is_public = '1')
AND (p.price > 0)
LIMIT 1
PHP:
$this->setTable( 'catalog' );
$Select = $this->select();
$Select->from( array( 'c' => $this->_name ), $Engine->getFrontendColumns( array( 'prefix' => 'c' ) ) );
$Select->joinLeft( array(
'p' => $this->getTable('catalog_products'),
), 'c.id = p.parent', array(
'MAX(price) as max_price',
'MIN(price) as min_price'
));
$Select->where( 'c.url_key = ?', $urlKey );
$Select->where( 'c.is_public = ?', '1' );
$Select->where( 'p.price > ?', '0' );
$Select->limit( 1 );
$Result = $this->fetchRow( $Select );