I’m not quite sure why with my query its not incrementing the number of logins by one its not even attaching it onto the query string.
public function update_logins($user_id)
{
$this->db->set('number_of_logins', 'number_of_logins'+1);
$this->db->where('user_id', $user_id);
$this->db->update('users_logins');
echo $this->db->last_query();
}
Althought i don’t know how codeigniter will work with the suggestion in comments, what i can tell you is:
Your +1 to the ‘number_of_logins’ will not yield the expected behavior because a string + a number usually gives an unexpected result depending on the content of the string.
Number parsing in PHP works by scanning the string for digits and number symbols. Anything it finds will be taken into account as a possible part of a number until it finds an invalid character.
In the context of a string with “number_of_logins” it will yield a value of 0 because there is nothing in that string that allows a number interpretation. But, a “10_number_of_logins” would generate a 10 and thus add a 1 would make 11.
UPDATE
For example:
Hope this helps