MySQL server left for CakePHP bake Console
I am currently studying pie. I'm in this console as stated in the book I downloaded from the internet. However, I was unable to advance one more step as I entered this error into the console:
PHP Warning: mysql_connect(): MySQL server has gone away in C:\wamp\www\cake\cake\libs\model\datasources\dbo\dbo_mysql.php on line 543
Warning: mysql_connect(): MySQL server has gone away in C:\wamp\www\cake\cake\libs\model\datasources\dbo\dbo_mysql.php on line 543
PHP Warning: mysql_connect(): Error while reading greeting packet. PID=2328 in C:\wamp\www\cake\cake\libs\model\datasources\dbo\dbo_mysql.php on line 543
My GUI is working fine as I am loading the Cake PHP home page into my localhost correctly. It even says that I am connected to the database. Does it have anything to do with the work path and the application path? This problem is driving me crazy. Thanks for the answers in advanced :)
+3
source to share
1 answer
It looks like the connection is being dropped while the shell is running.
This happened when a very large CSV was generated in a shell script between two model functions.
Adding the following after the CSV generator fixed the issue. It provides a connection to db
if (!mysql_ping()) {
$this->ModelName->getDatasource()->reconnect();
}
+5
source to share