[eluser]igniteflow[/eluser]
As the title says I've made a very simple tracker more as a learning exercise than anything else. I'm new to CI and would appreciate some constructive criticism as to how I'm implementing this and if it follows best practices. Here's the code:
I made a simple tracker, thought I'd post it here as it might be useful as a starting block or for people who don't need a fully featured version. I'm new to CI, so please point out any errors/bad practices, I'd appreciate it...
SQL
Code:
CREATE TABLE IF NOT EXISTS `tracker` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`ip` varchar(20) NOT NULL,
`browser` varchar(500) NOT NULL,
`url` varchar(500) NOT NULL,
`date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
I put this at the end of _footer.php which I call in the VIEW
Code:
<?php
$tracker['id'] = '';
$tracker['ip'] = $this->input->ip_address();
$tracker['browser'] = $this->input->user_agent();
$tracker['url'] = $_SERVER['REQUEST_URI'];
// insert data to db
$this->db->insert('tracker', $tracker);
?>
Is putting this code in the view file in this way appropriate or should it be somewhere else?