0

Please anyone help me to solved my case :

What should I add to my code, if the output from the code below is insert on the table in POSTGRES, and row that will be inserted are more than 1000 rows. When I running using this code below it appears the error :

Fatal error: Maximum execution time of 60 seconds exceeded in D: \ xampp \ htdocs \ BillingDeliveryInfo \ page2.php on line 45

Because it took so long query maybe

while($msisdn = pg_fetch_row($qaccount)){ 
if ($msisdn[4]==2){
    $insert1="insert into delin_bdi_rf 
              values ('$msisdn[1]',
                      '$m1[1] $msisdn[1] $m1[2] $msisdn[2] $m1[3] $msisdn[3] $m1[4]',
                       CURRENT_DATE);";
}else{
    $insert2="insert into delin_bdi_rf 
              values ('$msisdn[1]',
                      '$m2[1] $msisdn[1] $m2[2] $msisdn[3] $m2[3]',
                       CURRENT_DATE);";
}
    $qwer=$insert1.$insert2;
    $n=pg_query($qwer);
}   
oals
  • 210
  • 2
  • 9
Delinda Dyta
  • 187
  • 1
  • 2
  • 12
  • 1
    Try http://stackoverflow.com/questions/758945/whats-the-fastest-way-to-do-a-bulk-insert-into-postgres – Akhil Thayyil Sep 20 '16 at 07:08
  • Try to set: set_time_limit ( int $seconds ) in your php file. – Michael Sep 20 '16 at 07:09
  • 1
    Possible duplicate of [Fatal error: Maximum execution time of 30 seconds exceeded](http://stackoverflow.com/questions/5164930/fatal-error-maximum-execution-time-of-30-seconds-exceeded) – jannej Sep 20 '16 at 07:10
  • a) Use a transaction b) Instead `SELECT`ing a large resultset and making trivial inserts based on it, why don't you `INSERT INTO ... SELECT ...` which happens all inside the database (no round-trips)? – oals Sep 20 '16 at 10:34

1 Answers1

0

Try adding this in the beginning:

ini_set('max_execution_time', 300); //300 seconds = 5 minutes

It increases maximum execution time of script.

Nabeel
  • 183
  • 1
  • 10