Welcome Guest, Not a member yet? Register   Sign In
[Oracle + Active Record] Reset queries

I'm working on CI 1.5.4, *nix server, Oracle db.
I'm having a strange bug with Active Record.
Let's say I have a model called myNewModel with this 2 methods:

function getFirstArray(){
    $myFirstArray = array();
    $this->db->orderby("myOrderField", "desc");
    $query = $this->db->get();
    $myFirstArray = $query->result_array();
    return $myFirstArray;

function getSecondArray(){
    $mySecondArray = array();
    $this->db->orderby("myOtherOrderField", "desc");
    $query = $this->db->get();
    $mySecondArray = $query->result_array();
    return $mySecondArray;

First method gets a long list of stuff (articles i.e.).
Second method gets a list of 3 items (category i.e.).

When I call from my controller:

$myFirstArray = $this->myNewModel->getFirstArray();
$mySecondArray= $this->myNewModel->getSecondArray();

to pass data to the view, $myFirstArray is filled up with lots of records, and $mySecondArray has the same contents.
It seems like if CI has executed first query again (query executed and freeed in method getFirstArray() ) without resetting queries object, ignoring my second query ( in method getSecondArray() ).

I printed $this->db to screen from within the second method, and the object CI_DB_oci8_driver->queries has 2 queries in it.

I have $db["cache_on"] set to FALSE, anyway I tried to force cache delete and cache off before preparing select with active record, nothing to do... :-(

Somebody had my same problem?
I had a look in the forum search but didn't find anything...

thanks in advance to everybody

Try using $this->db->_reset_select() and $this->db->_reset_write(), you can find them in DB_active_rec.php.
Hope, it helps Smile

i am also having the same problem. and i've tried what you've said but still doesn't work.

this thread http://ellislab.com/forums/viewthread/49156/ helped me solved the problem.

Theme © iAndrew 2016 - Forum software by © MyBB