Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

zend-framework output Zend_Db_Table's select() statement generated query

i want to output the query generated by Zend_Db_Table's select() statement for testing porposes but i dont know how.

like image 839
rahim asgari Avatar asked Jul 16 '09 14:07

rahim asgari


2 Answers

It's actually really easy. The select object implements a toString method.

$select = $table->select()->....
echo $select; //prints SQL

Or

$sql = $select->__toString();
like image 130
David Snabel-Caunt Avatar answered Oct 13 '22 19:10

David Snabel-Caunt


or cast it to string and then use it:

(string)$table->select();
like image 35
obotezat Avatar answered Oct 13 '22 19:10

obotezat