Welcome Guest, Not a member yet? Register   Sign In
Creating a tracking table that is updated every day
#2

Found a solution, this is the code that worked for me: 

Code:
<?php
class Tracker_model extends CI_Model {
    #insert follower count 
    public function twitter_followers(){
        $query = $this->db->get('icos');
        if($query->num_rows() > 0) {
            foreach($query->result() as $row) {
                $ico_id = $row->id;
                $twitter_url = $row->twitter;

                $page = @file_get_contents($twitter_url);
                $followers = @explode("followers_count&quot;:", explode(",&quot;friends_count", $page)[0])[1];  

                $data = array (
                    'ico_id'      => $ico_id,
                    'twitter_url' => $twitter_url,
                    'year'        => date("Y"),
                    'month'       => date("m"),
                    'month_word'  => date("F"),
                    'day'         => date("d"),
                    'day_word'    => date("l"),
                    'week'        => date("W"),
                    'followers'   => $followers
                );

                $insert_followers = $this->db->insert('twitter_followers', $data);
            }
        } else {
            return false;
        }
    } 
}
?>

Now the question is, how to set up a cron for this function to run every 24 hours? And in some cases, the function stops if it exceeds 30 seconds.
Reply


Messages In This Thread
RE: Creating a tracking table that is updated every day - by wmx11 - 04-06-2018, 06:45 AM



Theme © iAndrew 2016 - Forum software by © MyBB