gpt4 book ai didi

PHP 异常 : how to include more information about problematic sql queries

转载 作者:行者123 更新时间:2023-11-29 05:38:04 25 4
gpt4 key购买 nike

好吧,这已经是我第一千次从 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。

最佳答案

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

关于PHP 异常 : how to include more information about problematic sql queries,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9057967/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com