开发者

CakePHP Reconnect to DB

开发者 https://www.devze.com 2023-02-13 16:02 出处:网络
I have a script that inserts an object into the database and then I have like 20 000 other little objects to be inserted. So I save the other objects into an array and save them afterwards.

I have a script that inserts an object into the database and then I have like 20 000 other little objects to be inserted. So I save the other objects into an array and save them afterwards.

But the server sais "MySQL Server has gone away"

Can I reconnect in some way to the database? Or can I disconnect after inserting the big object and after collecting a开发者_如何学Goll the small object to reconnect?


You can in your model.

$this->ModelName->getDatasource()->disconnect(); 
    //do stuff
$this->ModelName->getDatasource()->connect(); 
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号