Welcome Guest, Not a member yet? Register   Sign In
Having lots if insert into database for thread analytics
#1

(This post was last modified: 10-09-2016, 01:01 AM by wolfgang1983.)

I have a thread analytics table where each time a new user visits a page it insert the ip address and also a view of "1" and the thread id

If there are over a 1000 rows for each thread does it slow down the page?  Is it OK to create a new row for each new visit. I am just worried about how many rows I can have in my table.


PHP Code:
<?php

class Thread_model extends CI_Model {

    public function thread_analytics($thread_id) {
        $this->db->where('thread_id'$thread_id);
        $this->db->where('ip_address'$this->input->ip_address());
        $query $this->db->get($this->db->dbprefix 'thread_analytics');

        if ($query->num_rows() == 1) {

            return false;
        
        
} else {

            $data = array(
                'thread_id' => $thread_id,
                'ip_address' => $this->input->ip_address(),
                'views' => '1',
                'date_created' => date('Y-m-d H:i:s')
            );

            $this->db->insert($this->db->dbprefix 'thread_analytics'$data);
        }
    }

    public function total_thread_views($thread_id) {
        $this->db->where('thread_id'$thread_id);
        $this->db->where('views''1');
        return $this->db->count_all_results('thread_analytics');
    }

There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply


Messages In This Thread
Having lots if insert into database for thread analytics - by wolfgang1983 - 10-08-2016, 11:02 PM



Theme © iAndrew 2016 - Forum software by © MyBB