7

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

rahim asgari
  • 12,197
  • 10
  • 43
  • 53

2 Answers2

15

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

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

Or

$sql = $select->__toString();
David Snabel-Caunt
  • 57,804
  • 13
  • 114
  • 132
2

or cast it to string and then use it:

(string)$table->select();
fancyPants
  • 50,732
  • 33
  • 89
  • 96
obotezat
  • 1,041
  • 16
  • 20