Welcome Guest, Not a member yet? Register   Sign In
$this->db->affected_rows() not working
#1

[eluser]chuckleberry13[/eluser]
Looking for some help here. I am using CI's active record class with a MySql database and found that the $this->db->affected_rows() function would return 1 everytime instead of the number of updated/affected rows. What puzzled me more was I also tried the built in php function mysql_affected_rows() and it also returned 1.

Has anybody had this problem before or would know of a solution? Thanks ahead of time for the help.

This was the code I tried and updated several rows followed by the whole table and no matter how many rows I actually updated the result was always 1.

Code:
$num_rows = $this->db->update('user',array('role'=>5));
echo 'returned value'.$num_rows.'<br />';
echo 'count results'.$this->db->count_all_results().'<br />';
echo 'affected rows'.$this->db->affected_rows().'<br />';
echo 'build in:'.mysql_affected_rows();

These were the queries that were ran against the databae
Code:
0.0004      SELECT * FROM (`ci_sessions`) WHERE `session_id` = '321c8d852a69076026a7253caf4e2b8c' AND `ip_address` = '127.0.0.1' AND `user_agent` = 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; '
0.0003      UPDATE ci_sessions SET last_activity = 1213816300, session_id = '0602b5c8cff8000ac8260381361f0173' WHERE session_id = '321c8d852a69076026a7253caf4e2b8c'
0.0003      UPDATE `user` SET `role` = 5
0.0001      SELECT COUNT(*) AS `numrows`


Messages In This Thread
$this->db->affected_rows() not working - by El Forum - 06-18-2008, 01:28 PM
$this->db->affected_rows() not working - by El Forum - 06-18-2009, 06:05 AM
$this->db->affected_rows() not working - by El Forum - 06-18-2009, 06:09 AM
$this->db->affected_rows() not working - by El Forum - 06-18-2009, 07:00 AM
$this->db->affected_rows() not working - by El Forum - 06-18-2009, 07:15 AM
$this->db->affected_rows() not working - by El Forum - 06-18-2009, 09:35 AM
$this->db->affected_rows() not working - by El Forum - 06-18-2009, 09:42 AM
$this->db->affected_rows() not working - by El Forum - 06-18-2009, 09:48 AM
$this->db->affected_rows() not working - by El Forum - 06-18-2009, 06:26 PM
$this->db->affected_rows() not working - by El Forum - 06-18-2009, 06:37 PM



Theme © iAndrew 2016 - Forum software by © MyBB