Right now I have something like this in my CodeIgniter model:
<?php
$array = array(...over 29k IDs...);
$update = array();
foreach ($array as $line) {
$update[] = array('id' => $line, 'spintax' => $this->SpinTax($string));
### $this->SpinTax parses the spintax from a string I have. It has to be generated for each row.
}
$this->db->update_batch('table', $update, 'id');
?>
The first 20k records get updated just fine, but I get a 504 Gateway Time-out before it completes.
I have tried increasing the nginx server timeout to something ridiculous (like 10 minutes), and I still get the error.
What can I do to make this not timeout. I’ve read many answers and HOW-TOs to segment the update, but I continue to get the server timeout. A PHP or CodeIgniter solution would be excellent, and I need to deploy this code to multiple servers that might not be using nginx (similar error in Apache).
Thanks in advance.
You’ll likely need to run this through command line and
set_time_limit(0). IF you’re in codeigniter, check this out on how to run a command line through the user guide. http://codeigniter.com/user_guide/general/cli.htmlNow, before you do that, you mentioned you are using array chunk. If you’re getting all the values from the database, no need to use
array_chunk. Just set a get variable for instance./your/url?offset=1000, when that finishes, do a redirect to the same thing, but with 2000 and so on until it finishes.
Not the nicest or cleanest, but will likely get it done.