0

hi don't know how to get out of this situation i am trying to increase the max_execution_time to 5000 for e.g ini_set('max_execution_time',5000). it do shows the execution_time set to 5000 on echo ini_get('max_execution_time') however it dosen't work as connection with server closes early than 5000 sec.

I am trying to fetch XML with the API and then converting that data in array and that array afterwards is being used in loop to insert array values in my database. I am using codeignitor please see the below code.

My controller

public function get_chassis_badge_detail()
    {
        $this->load->model('md_api_test','md_api');
        if($this->md_api->get_chassis_badge_detail())
        {
            $this->load->view('api_test',['car_detail' => '']);
        }
    }

My Model:

public function get_chassis_badge_detail()
{
    //// for kuzov insertion in to database from stats auction

    $this->load->library('auction_api');
    $query = "select count(distinct kuzov) from stats";
    $total_kuzov = $this->auction_api->aj_get_clean($query);
    $cycle_end = round($total_kuzov[0]['TAG0']/250)+1;

    $query = "select kuzov,model_id from stats group by kuzov order by model_id ASC";

    $arr = '';
    for($k=0; $k<($cycle_end); $k++)
    {
        $query .= " limit ".($k*250).",250";
        $arr[] = $this->auction_api->aj_get_clean($query);
        $query = "select kuzov,model_id from stats group by kuzov order by model_id ASC";

        if (isset($arr[$k][0]))
        {
            for($b=0; $b<count($arr[$k]); $b++)
            {
                $trim_val=trim($arr[$k][$b]['KUZOV']);
                if(!empty($trim_val))
                {
                    $this->db->query("INSERT INTO `dd_chassis_badge`(`model_id`, `badge`) VALUES ('".$this->db->escape_str($arr[$k][$b]['MODEL_ID'])."','".$this->db->escape_str($arr[$k][$b]['KUZOV'])."');");
                }
            }
        }
        else
        {
            unset($arr[$k]);
            break;
        }
    }

    return true;
}
Abdal Asif
  • 47
  • 13

1 Answers1

0

Is there a change you're getting an error (and therefore the server is stopping earlier) but not seeing it? Do you have a php.ini file set to show you php errors?

Saulo M
  • 173
  • 2
  • 7
  • yes the php.ini file is set to show error. the script seems to work fine till 19 cycle of loop and doesn't throw any error if it is increased than the time outs. the array i am trying to insert in to my database consist of 19000+records. – Abdal Asif Jun 15 '17 at 20:56
  • Hmmm... take a look at this: https://stackoverflow.com/a/1590644/7399485. Could this be the case? – Saulo M Jun 15 '17 at 21:13
  • FWIW João's link pertains to safe mode, which seems like it was removed in PHP 5.4, so if you're using a later PHP, it may be unlikely that this is your issue. See: http://php.adamharvey.name/manual/en/features.safe-mode.php – Nelson Frew Apr 13 '22 at 03:23