View Zend_Db_Select query

Posted March 31, 2008, 11:26am In: Zend Framework

Saw something in #zftalk that could be considered a no-brainer, but since the question was posed I’ll reproduce the answer here.

Rather than turning on the profiler to see what kind of query is being generated, use the __toString() magic method.

This should produce something like:

This entry was posted on Monday, March 31st, 2008 at 11:26 am and is filed under Zend Framework. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

2 Responses...

Eric Coleman

No need even for that __toString()…

echo $select works fine… it’s how the magic method is intended to be used.

Type-casting works too if you want to var_dump the variable, ala:

var_dump((string) $select);

Ryan Brooks

Eric,

My mistake, I didn’t even bother to check. You’re entirely right! Thanks for the tip!

-Ryan

Leave a reply...

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>