1

我有这个查询(PostgreSQL):https ://gist.github.com/patrickmaciel/74c72cdf1984bdcde804

它适用于 PgAdmin、EMS 客户端、Navicat、Postgres 命令行等。我在 2 个版本的 Postgres 数据库中测试了这个查询:

  • 8.2:19秒
  • 9.2:16毫秒

但在 CakePHP 中不起作用$this->query($sql);2013-03-11 17:59:48 错误:[FatalErrorException] 超过 30 秒的最大执行时间

CakePHP 是否以不同的方式执行/运行此查询?

#8 ...........................\app\Controller\Component\CommonCheckComponent.php(64): CommonCheckComponent->validateCheckPromotion(Array, Array, NULL)
#9 ...........................\app\Controller\Component\CommonCheckComponent.php(40): CommonCheckComponent->applyCheckPromotion(Array, Array)
#10 ...........................\app\Controller\Component\CommonTableComponent.php(56): CommonCheckComponent->insertDefaultPromotions(Array)
#11 ...........................\app\Controller\ChecksController.php(42): CommonTableComponent->putTableInCheck(Array, '374')
#12 [internal function]: ChecksController->printCheck('28')
#13 ...........................\lib\Cake\Controller\Controller.php(486): ReflectionMethod->invokeArgs(Object(ChecksController), Array)
#14 ...........................\lib\Cake\Routing\Dispatcher.php(187): Controller->invokeAction(Object(CakeRequest))
#15 ...........................\lib\Cake\Routing\Dispatcher.php(162): Dispatcher->_invoke(Object(ChecksController), Object(CakeRequest), Object(CakeResponse))
#16 ...........................\app\webroot\index.php(109): Dispatcher->dispatch(Object(CakeRequest), Object(CakeResponse))
#17 {main}
2013-03-11 17:59:48 Error: Fatal Error (1): Maximum execution time of 30 seconds exceeded in [...........................\lib\Cake\Model\Datasource\DboSource.ph
p, line 460]
2013-03-11 17:59:48 Error: [FatalErrorException] Maximum execution time of 30 seconds exceeded
Request URL: /patrick/chima-rms/chimarms/checks/printCheck/28
Stack Trace:
#0 ...........................\lib\Cake\Error\ErrorHandler.php(184): ErrorHandler::handleFatalError(1, 'Maximum executi...', 'C:\www\patrick\...', 460)
#1 [internal function]: ErrorHandler::handleError(1, 'Maximum executi...', 'C:\www\patrick\...', 460, Array)
#2 ...........................\lib\Cake\Core\App.php(927): call_user_func('ErrorHandler::h...', 1, 'Maximum executi...', 'C:\www\patrick\...', 460, Array)
#3 ...........................\lib\Cake\Core\App.php(900): App::_checkFatalError()
#4 [internal function]: App::shutdown()
#5 {main}
2013-03-11 17:59:49 Error: Fatal Error (1): Maximum execution time of 30 seconds exceeded in [...........................\lib\Cake\Model\Datasource\CakeSession.
php, line 616]
2013-03-11 17:59:49 Error: [FatalErrorException] Maximum execution time of 30 seconds exceeded
Request URL: /patrick/chima-rms/chimarms/checks/printCheck/28
Stack Trace:
#0 ...........................\lib\Cake\Error\ErrorHandler.php(184): ErrorHandler::handleFatalError(1, 'Maximum executi...', 'C:\www\patrick\...', 616)
#1 [internal function]: ErrorHandler::handleError(1, 'Maximum executi...', 'C:\www\patrick\...', 616, Array)
#2 ...........................\lib\Cake\Core\App.php(927): call_user_func('ErrorHandler::h...', 1, 'Maximum executi...', 'C:\www\patrick\...', 616, Array)
#3 ...........................\lib\Cake\Core\App.php(900): App::_checkFatalError()
#4 [internal function]: App::shutdown()
#5 {main}
2013-03-11 18:00:11 Error: Fatal Error (1): Maximum execution time of 30 seconds exceeded in [...........................\lib\Cake\Utility\Debugger.php, line 47
3]
2013-03-11 18:00:11 Error: [FatalErrorException] Maximum execution time of 30 seconds exceeded
Request URL: /patrick/chima-rms/chimarms/checks/printCheck/28
Stack Trace:
#0 ...........................\lib\Cake\Error\ErrorHandler.php(184): ErrorHandler::handleFatalError(1, 'Maximum executi...', 'C:\www\patrick\...', 473)
#1 [internal function]: ErrorHandler::handleError(1, 'Maximum executi...', 'C:\www\patrick\...', 473, Array)
#2 ...........................\lib\Cake\Core\App.php(927): call_user_func('ErrorHandler::h...', 1, 'Maximum executi...', 'C:\www\patrick\...', 473, Array)
#3 ...........................\lib\Cake\Core\App.php(900): App::_checkFatalError()
#4 [internal function]: App::shutdown()
#5 {main}

为什么?


我在用着:

  • CakePHP 2.3.0
  • PostgreSQL 9.2
  • PHP 5.3.9
  • 阿帕奇 2.2
  • 视窗 7 x64
4

1 回答 1

2

默认情况下,PHP 脚本的最大执行时间为 30 秒。运行这条 SQL 时,返回和处理数据的时间大于 30 秒。您需要增加最大执行时间或优化您的查询。尝试 set_time_limit(0); 在脚本的顶部。

于 2013-08-10T07:42:31.877 回答