Database Entering even without PHP script execution

Asked

Viewed 30 times

0

Hail!!!

I have a PHP script that breaks sentences in array and inserts word by word in BD. Until then all right, the bid starts when even without the script being active or session it remains foolishly Inserting, now reached an hour after the script’s interruption.

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 into a private variable, both of the class and the crud. What can I be missing? Because the volume is not so big that I did the test and have been able to insert a base of 4 to 5 lines per second normally in other codes in 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));            
}    
  • Without you calling it inserts records? Do you have any scheduling/crontab calling this file? puts tbm the code you call InsertWordMessage()

  • It seems to me that your script does an Insert per word, not for sentences. It breaks by space. That’s the very intention?

  • 1

    Add the above code, have no scheduling. This code is a fragment of a Facebook bot that is running 24 hours, what worries me is that I need the words in real time of what goes into the alert system and ran for almost 1 hour with nothing running in the script.

  • Yes Bacco the intention is this, it makes several Insert, that of word use for recurring, to plot word cloud

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.