Quantcast
Channel: CodeIgniter Forums - All Forums
Viewing all articles
Browse latest Browse all 14348

Having lots if insert into database for thread analytics

$
0
0
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');
    }


Viewing all articles
Browse latest Browse all 14348

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>