CodeIgniter Forums
[Oracle + Active Record] Reset queries - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: [Oracle + Active Record] Reset queries (/thread-2457.html)



[Oracle + Active Record] Reset queries - El Forum - 08-07-2007

[eluser]Unknown[/eluser]
Hallo,
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:

Code:
function getFirstArray(){
    
    $myFirstArray = array();
    $this->db->select('*');
    $this->db->from('firstTable');
    $this->db->orderby("myOrderField", "desc");
    $query = $this->db->get();
    $myFirstArray = $query->result_array();
    $query->free_result();
        
    return $myFirstArray;
    
}

function getSecondArray(){
    
    $mySecondArray = array();
    $this->db->select('*');
    $this->db->from('secondTable');
    $this->db->orderby("myOtherOrderField", "desc");
    $query = $this->db->get();
    $mySecondArray = $query->result_array();
    $query->free_result();
        
    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:

Code:
$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
Alex


[Oracle + Active Record] Reset queries - El Forum - 08-26-2007

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


[Oracle + Active Record] Reset queries - El Forum - 10-25-2007

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


[Oracle + Active Record] Reset queries - El Forum - 10-25-2007

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