[eluser]tinawina[/eluser]
I have a click-through routine that simply adds 1 to two database table fields when a link is clicked. One field keeps count of how many times a link is clicked in a particular month, the other keeps count of how many times the link is clicked total in a year (so it's a cumulative count of all clicks).
I have this working flawlessly in an old site (procedural code), and if I run my query directly in the phpMyAdmin SQL window, it works too. But when I use CI, instead of increasing by 1, the field is increased by 2 - ?
I'm using a library in my CI site to handle this. Here's my code (I have db interactions in this library file rather than a separate model right now just to keep troubleshooting simple):
Code:
class Clicks
{
function __construct ()
{
$this->CI =& get_instance();
}
function updateClickData($identifier)
{
$month = date('M');
$sql = "UPDATE clicks_listing_page SET $month=$month+1, clicks_total=clicks_total+1 WHERE id = '$identifier'";
$this->CI->db->query($sql);
}
}
I call up the library in my controller only once (thought maybe I was doing it twice...) like this:
Code:
$this->load->library('clicks');
$this->clicks->updateClickData($this->identifier);
I've output this query in my browser and copy/pasted it into phpMyAdmin -- run it and it bumps up the count on these two fields by 1. Why does the very same query increase by 2 in CI? Any help - appreciated!