Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set command timeout in yii?

Tags:

php

mysql

yii

I am struggling to find where to set the command timeout in Yii for MySql database (some queries are taking a while to run).

In the source code the file protected/config/main.php has these settings:

'db'=>array( 'connectionString' => 'mysql:host=xxx;dbname=xxx;port=xxx;timeout=100;', 'emulatePrepare' => true, 'username' => 'xxx', 'password' => 'xxx', 'charset' => 'utf8', 'schemaCachingDuration'=>3600, ),

The timeout seems to apply to connections, and command timeout default is 30 seconds (that's the one I need to increase).

Web pages fetching from db usually fail with Fatal error: Maximum execution time of 30 seconds exceeded in \YiiRoot\framework\db\CDbCommand.php on line 508.

line 508 is

$this->_statement->execute();

so obviously is a query timeout.

like image 557
Fernando Gonzalez Sanchez Avatar asked Oct 19 '25 11:10

Fernando Gonzalez Sanchez


1 Answers

This is not a mysql error, it is a php error. Fatal error: Maximum execution time of 30 seconds is set by the php.ini setting max_execution_time the default is 30. You can either change your php.ini file, or you can adjust it with .htaccess or on the individual function you can use the set_time_limit() command.

http://www.php.net//manual/en/function.set-time-limit.php

like image 107
Pitchinnate Avatar answered Oct 21 '25 00:10

Pitchinnate



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!