![]() |
DB Where function doesn't resets after running query - 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: DB Where function doesn't resets after running query (/showthread.php?tid=1973) |
DB Where function doesn't resets after running query - El Forum - 07-09-2007 [eluser]Benjamin David[/eluser] Hi ! I'm having a weird bug with the active record class. It's as if it remembers the where conditions I had made in previous queries. Here it is : Here is the first function, it's a recursive one : Code: function delete_media_entry($id) { Here is the second one that gets the media: Code: function get_media($id) I have some data in the table but the errors I'm getting are weird. In that case, I only ask for one row, I give the id and I'm awaiting a single row answer. But at some point, there is something that makes the class remember my previous where condition, but can't get to handle where... I'm wondering why it doesn't the db where function doesn't seem to reset after each query has run. By the way, here's a copy of the errors I'm getting. Thanks for helping ! Code: get (2) DB Where function doesn't resets after running query - El Forum - 07-10-2007 [eluser]OwanH[/eluser] CI Ben, have you configured CI to cache your database queries? If you have be sure to clear the cache each time the database is updated by an insert/update/delete operation. DB Where function doesn't resets after running query - El Forum - 07-10-2007 [eluser]marcalj[/eluser] After every finish SELECT make a free_result of a query. Code: $query->free_result(); I hope it helps. Salut! DB Where function doesn't resets after running query - El Forum - 07-10-2007 [eluser]Benjamin David[/eluser] Hi and thanks for answering ! OwanH, I checked and didn't see anything activated. I have never activated it actually. marcalj, thanks that's exactly what I was looking for but it unfortunately, it doesn't work. I hope I'll get some other ideas, otherwise I'll have to use a normal SQL request instead of active records... DB Where function doesn't resets after running query - El Forum - 07-10-2007 [eluser]OwanH[/eluser] CI Ben, could you post the code for your Media_model::get_media method? I'd like to take a look at it to see if there could anything in the method that could be causing the problem. From the errors you have shown, I'm assuming that the SELECT query generated by this method is not right. DB Where function doesn't resets after running query - El Forum - 07-11-2007 [eluser]Benjamin David[/eluser] Hi ! First of all, thanks for taking the time to take a look at this. Here is my get_media function : Code: function get_media($id) I also give you the set_db_object function. It should be useless, but just in case... Code: function set_db_object($media_row) { DB Where function doesn't resets after running query - El Forum - 07-11-2007 [eluser]OwanH[/eluser] OK this may seem like a crazy suggestion but try replacing but try replacing these two lines: Code: $this->db->where('id', $id); with this line: Code: $query = $this->db->getwhere($this->tables['media'], array('id' => $id)); To be honest I actually don't see anything wrong with your code, and I don't think you should be getting the problem you are getting, especially since you have not enabled CI's query caching, but hey you could give this a try and see if it helps ![]() |