开发者

Zend Framework output ready prepared statement

开发者 https://www.devze.com 2023-01-12 06:40 出处:网络
How to output sql statement right before it\'s launched? To check all placed data inside prepared sta开发者_JAVA技巧tement.Zend_Db doesn\'t have a mechanism itself to output the sql statements that i

How to output sql statement right before it's launched?

To check all placed data inside prepared sta开发者_JAVA技巧tement.


Zend_Db doesn't have a mechanism itself to output the sql statements that it generates. What you can do is modify the public method "query" in Zend/Db/Adapter/Abstract.php(line 445 in 1.10.6) to output the $sql local variable. The query method is called by both the update and insert methods.


There is actually a way to output the SQL it generates

$select = $db->select()->from('elements')
                       ->where('id = ?', $this->_Id);
$sql = $select->__toString();
echo $sql;


You can also use:

echo (string) $select;

0

精彩评论

暂无评论...
验证码 换一张
取 消