Welcome Guest, Not a member yet? Register   Sign In
Keeping statistics....
#7

[eluser]codelearn[/eluser]
Nick,

That might make sense... let me know if your on a similar project and do something like that. I will do the same.

Update:

For anyone who cares, this is how it was implemented (Following Michaels suggestion):

Database Table:
---------------

Code:
CREATE TABLE `rest_stats` (
  `id` int(12) NOT NULL auto_increment,
  `rest_id` int(12) NOT NULL default '0',
  `date` date NOT NULL default '0000-00-00',
  `hits` int(125) NOT NULL default '0',
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=31 ;

Controller Code:

Code:
//compute stats
$todays_date = date("Y-m-d");
$this->db->where('rest_id',$IRIresults->id); //which restaurant
$this->db->where('date',$todays_date);
$rest_stats = $this->db->get('rest_stats');
      if($rest_stats->num_rows() > 0){
                    $this->db->query('UPDATE rest_stats set hits = hits + 1 WHERE rest_id = "'.$IRIresults->id.'" AND date = "'.$todays_date.'"');
                } else {
                    $this->db->set('hits','1');
                    $this->db->set('rest_id',$IRIresults->id);
                    $this->db->set('date',$todays_date);
                    $this->db->insert('rest_stats');
                }
//end


Messages In This Thread
Keeping statistics.... - by El Forum - 12-12-2007, 01:29 PM
Keeping statistics.... - by El Forum - 12-12-2007, 01:32 PM
Keeping statistics.... - by El Forum - 12-12-2007, 01:34 PM
Keeping statistics.... - by El Forum - 12-12-2007, 01:58 PM
Keeping statistics.... - by El Forum - 12-14-2007, 01:41 PM
Keeping statistics.... - by El Forum - 12-14-2007, 02:30 PM
Keeping statistics.... - by El Forum - 12-14-2007, 02:53 PM



Theme © iAndrew 2016 - Forum software by © MyBB