4

Are there any ways to convert Zend db Select or Zend DB query to SQL query before querying the database? Any other workarounds?

As I want to build a more complex SQL query that Zend DB cannot handle, without modifying my current Zend db code structure.

halfpastfour.am
  • 5,764
  • 3
  • 44
  • 61
Capitaine
  • 1,923
  • 6
  • 27
  • 46
  • You are going to handcode an SQL query ? I am not sure how you can do that without changing or removing the Zend_Db_Select specific code – Amit Dugar Sep 02 '12 at 17:24

4 Answers4

6

You can convert a Zend db Select object to string by $select->__toString()

Nandakumar V
  • 4,317
  • 4
  • 27
  • 47
3

You can always echo $select which will return string with plain SQL query.

kasztelan
  • 1,731
  • 3
  • 17
  • 24
3

For a Zend\Db\Sql\Select object (In Zend 2.2),

$select->getSqlString(); worked for me.

edi9999
  • 19,701
  • 13
  • 88
  • 127
1

For Zend Framework 1.* you can use assemble

echo $select->assemble();
Sajjad Ashraf
  • 3,754
  • 1
  • 34
  • 35