好吧,这是千分之一次,当我从php异常中得到一些无用的信息时。它总是这样:
Message: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '))' at line 1
Stack trace:
#0 /usr/share/php5/Zend/Db/Statement.php(300): Zend_Db_Statement_Pdo->_execute(Array)
#1 /usr/share/php5/Zend/Db/Adapter/Abstract.php(479): Zend_Db_Statement->execute(Array)
#2 /usr/share/php5/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('UPDATE `product...', Array)
#3 /usr/share/php5/Zend/Db/Adapter/Abstract.php(634): Zend_Db_Adapter_Pdo_Abstract->query('UPDATE `product...', Array)
#4 /usr/share/php5/Zend/Db/Table/Abstract.php(1132): Zend_Db_Adapter_Abstract->update('products', Array, 'shop = '1' AND ...')
#5 /var/www/simira/html/application/models/DbTable/Products.php(250): Zend_Db_Table_Abstract->update(Array, 'shop = '1' AND ...')
#6 /var/www/simira/html/application/controllers/ShopsController.php(567): Application_Model_DbTable_Products->updatePriceByShopCategories(Array, '1')
#7 /var/www/simira/html/application/controllers/ShopsController.php(597): ShopsController->processGlobalChangeRequest('Price', 'Products')
#8 /usr/share/php5/Zend/Controller/Action.php(516): ShopsController->globalChangePriceAction()
#9 /usr/share/php5/Zend/Controller/Dispatcher/Standard.php(295): Zend_Controller_Action->dispatch('globalChangePri...')
#10 /usr/share/php5/Zend/Controller/Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#11 /usr/share/php5/Zend/Application/Bootstrap/Bootstrap.php(97): Zend_Controller_Front->dispatch()
#12 /usr/share/php5/Zend/Application.php(366): Zend_Application_Bootstrap_Bootstrap->run()
#13 /var/www/simira/html/public/index.php(29): Zend_Application->run()
#14 {main}
我现在真正需要看的是查询。如何将此信息包含在抛出的异常中?我能否在query('UPDATE product...', Array)
中删除查询?我想知道我是否可以在全球范围内申请解决方案。如果有帮助,我就在Zend Framework上。
答案 0 :(得分:3)
Zend Framework包含一个很棒的数据库分析器界面。
我个人最喜欢的是FirePHP实现。这会在Firebug控制台中显示完整的查询信息。
请参阅http://framework.zend.com/manual/en/zend.db.profiler.html#zend.db.profiler.profilers.firebug
您还可以启用MySQL查询日志记录。见http://dev.mysql.com/doc/refman/5.5/en/query-log.html