2008年7月30日星期三

Re: re[2]: [fw-db] Using the Zend_Db_Table to return referenced row values

Indeed PDO is much more readable - with a good indentation implemented. I
think there is definitely a place for Db Object Models one just has to find
a balance between the two ie. when it is appropriate and convienient to go
the object way or to simply stick to plain sql. I find plain sql much more
simpler especially when you have written and testing your queries before
hand. You simply copy and paste and not have to worry about the intricacies
of how a Frameworks interpretes nested joins or queries :)

Am using a combination of both for now.

monk.e.boy wrote:
>
> >> Your query is this:
>
> I ask thee, which is easier to read and understand? ::
>
>
> $sql = <<<EOT
>
>
> SELECT e.eventName, v.VenueName, c.City
> FROM EventVenue ev
> LEFT JOIN Event e ON ev.eventid=e.eventid
> LEFT JOIN Venue v ON ev.venueid=v.venueid
> LEFT JOIN Area a ON e.areaid=a.areaid
> LEFT JOIN City c ON a.cityid=c.cityid;
>
> EOT;
>
> ---- or ----
>
> $sql = $this->select()->setIntegrityCheck(false)
> ->from($this, array() )
> ->joinLeftUsing( array('e'=>'Event'), 'EventId', array('EventName') )
> ->joinLeftUsing( array('v'=>'Venue'), 'VenueId', array('VenueName') )
> ->joinLeft( array('a'=>'Area'), 'e.AreaId = a.AreaId', array() )
> ->joinLeft( array('c'=>'City'), 'a.CityId = c.CityId', array('City')
> );
>
> Object models are a neat idea, but good god, the code is a mess. It's
> starting to look like Perl....
>
> monk.e.boy
>


-----
dee
--
View this message in context: http://www.nabble.com/re-2-%3A--fw-db--Using-the-Zend_Db_Table-to-return-referenced-row-values-tp18728740p18729744.html
Sent from the Zend DB mailing list archive at Nabble.com.

没有评论: