Database inserting even without PHP script execution

0

Save!

I have a PHP script that breaks phrases into array and inserts word by word into BD. So far so good, the bidding starts when even without the script being active or session it stays inserting madly, now it came within an hour after the script was interrupted.

I'm using Postgres + PDO + PHP

private function InsertWordMessage( $id, $type, $text)
{
    $array = explode(' ',$text);

    foreach (  $array as $key ): 
       $this->insert->InsertWord($id,$type,$key);
    endforeach;
}

I am loading the instances directly into the construct and setting them to a private variable, both class and crud. What can I let go of? Because the volume is not so great once I took the test and I have been able to insert a base of 4 to 5 lines per second usually in other codes on pg.

 $this->pack = json_decode($this->getToken($token,$secret,$fields), true);

    if(count($this->pack)<25)
    {$updated = 0;}
    else{$updated=1;}

    foreach($this->pack as $key => $value):
        if(!isset($value['picture'])) :  $value['picture'] = 'imagem/post.jpg' ; endif ;
        if(!isset($value['message'])) : $value['message']  = 'imagem incorporada' ; endif ;           
        if(!isset($value['permalink_url'])) : $value['permalink_url'] = 'not a link set' ; endif ;            
        if(!isset($value['name'])) : $value['name'] = 'not a name set' ; endif ;

        $idpost = $value['id'];
        $ps_idpage = $this->guide[0];
        $ps_date = \TimeConver::GMTtoUTC($value['created_time']['date'], "Y-m-d H:i:s");
        $ps_categoty = $value['type'];
        $ps_picture = $value['picture']; 
        $ps_name = $value['name'];
        $ps_message = $value['message'];
        $ps_link = $value['permalink_url'];

        $this->getSentiment($ps_message);

        $this->insert->InsertUserAtivity($idpost,'POST',$ps_date,$this->sentiment) ;

        if ($ps_message != 'imagem incorporada' or ' ') : $this->InsertWordMessage($idpost, 'POST', $ps_message) ;
        else : $sent =  $this->InsertWordMessage($idpost, 'POST',$ps_name) ;  
        endif ;         

        $this->insert->InsertPost($idpost,$ps_idpage,$ps_date,$ps_categoty,$ps_picture,$ps_name,$ps_message,$ps_link) ;

        $ps = new Executor();        
        $ps->PostSummary($idpost)->CollectPostSummary();
    endforeach;

    do
    {               
        $this->pack = $this->response;
        if(count($this->pack)<25)
        {$updated=0;}
        else{$updated=1;}

        foreach($this->pack as $key => $value):
            if(!isset($value['picture'])) :  $value['picture'] = 'imagem/post.jpg' ; endif ;
            if(!isset($value['message'])) : $value['message']  = 'imagem incorporada' ; endif ;           
            if(!isset($value['permalink_url'])) : $value['permalink_url'] = 'not a link set' ; endif ;            
            if(!isset($value['name'])) : $value['name'] = 'not a name set' ; endif ;

            $idpost     = $value['id'];
            $ps_idpage  = $this->guide[0];
            $time       = $value['created_time']->format("Y-m-d H:i:s");
            $ps_date    = \TimeConver::GMTtoUTC($time, "Y-m-d H:i:s");
            $ps_categoty= $value['type'];
            $ps_picture = $value['picture']; 
            $ps_name    = $value['name'];
            $ps_message = $value['message'];
            $ps_link    = $value['permalink_url'];

            $this->getSentiment($ps_message);

            $this->insert->InsertUserAtivity($idpost,'POST',$ps_date,$this->sentiment) ;

            if ($ps_message != 'imagem incorporada' or ' ') : $this->InsertWordMessage($idpost, 'POST', $ps_message) ;
                else : $sent =  $this->InsertWordMessage($idpost, 'POST',$ps_name) ;  
            endif ;         

            $this->insert->InsertPost($idpost,$ps_idpage,$ps_date,$ps_categoty,$ps_picture,$ps_name,$ps_message,$ps_link) ;

            $ps = new Executor();        
            $ps->PostSummary($idpost)->CollectPostSummary();               
        endforeach;
    }
    while($this->response = $this->fb->next($this->response));            
}    
    
asked by anonymous 19.08.2016 / 00:05

0 answers