![]() |
$this->db->affected_rows() doesnt return no. rows deleted??? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: $this->db->affected_rows() doesnt return no. rows deleted??? (/showthread.php?tid=2480) |
$this->db->affected_rows() doesnt return no. rows deleted??? - El Forum - 08-07-2007 [eluser]the real rlee[/eluser] Hi guys, i was reading the user guide and supposedly an inbuilt hack in the Active Record class for mysql should make $this->db->affected_rows() return the actual rows deleted...But i cant seem to get it to do so. My sql definitely deletes the record Code: $this->db->delete('gallery_photo', array('gallery_photo_id' => (int)$gallery_photo_id)); Am i missing something? $this->db->affected_rows() doesnt return no. rows deleted??? - El Forum - 08-09-2007 [eluser]the real rlee[/eluser] Hate to bump this, but i really would like a solution lol. $this->db->affected_rows() doesnt return no. rows deleted??? - El Forum - 08-09-2007 [eluser]Derek Allard[/eluser] If you echo out $affected_rows without your if statement, what do you see? What might be happening is that you are removing a single row, thus CI is returning "1" that is evaluating to true? Thus, your code is really if (true == false) $this->db->affected_rows() doesnt return no. rows deleted??? - El Forum - 08-10-2007 [eluser]Michael Wales[/eluser] With his code, if it was deleting a single row - his code would still not execute the logging and such. Code: if ($affected_rows == 0) { // if (true == false) I agree, echoing out $affected_rows is the first step in solving this issue though. Does $affected_rows in fact = 0? What if affected_row = FALSE and it's a completely seperate issue? $this->db->affected_rows() doesnt return no. rows deleted??? - El Forum - 08-10-2007 [eluser]Derek Allard[/eluser] [quote author="walesmd" date="1186777143"]With his code, if it was deleting a single row - his code would still not execute the logging and such.[/quote] Yeah, that was the point I was trying (inarticulately) to make ![]() Quote:I agree, echoing out $affected_rows is the first step in solving this issue though. Does $affected_rows in fact = 0? What if affected_row = FALSE and it's a completely seperate issue? You bet! Let us know what your echo reveals. |