CakePHP Connect to DB

I have a script that inserts an object into a database, and then I have 20,000 other small objects that need to be inserted. Therefore, I save other objects in an array and save them later.

But the server servers "MySQL Server are gone"

Is there any way to connect to the database? Or can I disconnect after inserting a large object and after collecting the entire small object for reconnection?

+3
source share
1 answer

You can in your model.

$this->ModelName->getDatasource()->disconnect(); 
    //do stuff
$this->ModelName->getDatasource()->connect(); 
+6
source

Source: https://habr.com/ru/post/1794732/


All Articles