Marco:
Simon posted me the following yesterday on another thread:

<snip>
Hi Gunter


The new Zend_Db_Table proposal has been committed to the incubator -
you can download that and give it a try. It allows a query like so:-


$myModel = new Customer();
$rows = $myModel->fetchAll($myModel->select()->join(array('ci' =>
'cities'), 'ci.city_id = customers.city_id', array())->order('ci.name
DESC'));


You can reference the JOINed tables any way you like as long as they
don't form part of the returned columns (that will throw an error).
Otherwise you can sort on them, reference them in WHERE clauses, etc.


Bear in mind the new component hasn't any unit tests yet, but they are
performing well so far in the apps I've deployed them in.


Kind regards
</snip>

Might work for you as well!
HTH

Gunter

On Nov 15, 2007 1:13 AM, Marco <[EMAIL PROTECTED]> wrote:
>
> On 14/11/2007, Gunter Sammet <[EMAIL PROTECTED]> wrote:
>
>
>
> > IIRC you can't do this with Zend_DB at the moment. You will have to
> > create your SQL manually using Zend_DB_Select:
> > e.g.
> > <code>
> >         $select = $db0->select()
> >                       ->from( array('p' => 'photos'),
> > array('p.photo_id', 'p.photo_name', 'p.photo_tn', 'p.photo_image',
> > 'p.location_link', 'p.keyword_id_primary', 'p.keyword_id_secondary',
> > 'p.photo_desc', ' p.photo_month', 'p.photo_year') )
> >                       ->join(array('m' => 'municipalities'), 'p.mun_id
> > = m.mun_id', array('m.mun_name'));
> >
> >                     $select->where(
> > $db0->quoteIdentifier('m.population') . ' > ?', (int)$munSize[0] )
> >                            ->where(
> > $db0->quoteIdentifier('m.population') . ' < ?', (int)$munSize[1] );
> >
> >                 $select->where(
> > $db0->quoteIdentifier('lpp.location_package_id') . ' = ?',
> > $this->_locationPackageId )
> >                        ->join(array('lpp' =>
> > 'location_package_photos'), 'lpp.photo_id = p.photo_id')
> >                        ->order( array('sort_order', 'package_new') );
> >
> > See http://framework.zend.com/manual/en/zend.db.select.html
> > HTH
> >
> > Gunter
> > </code>
>
> Thanks Gunter, I will use this approach instead.
>
> Regards
>
> Marco
>

Reply via email to