Retrieve where clauses in CodeIgniter Activerecord
10:27 01 Jun 2011

Is there a way to retrieve what the "where" clauses i have added in my query? I use a foreach statement to add the columns I want to add in the where clause for the current query but, since the clause could be empty (no columns added, 0 iterations in the foreach) the query would retrieve all the records in the database because no restrictions where made. Of course I could use a boolean variable to know wheter the foreach is making at least 1 iteration but I would like to know whether it is possible to retrieve information related to the query i'm making. Sorta the code i'm using:

foreach($columns as $column => $value){
    if($column!=''){
        $this->db->where($column,$value);
    }
}
$this->db->get('mytable');

Some explanation:

If $column is an emptry string i don't add it to the query.

$columns var is an object (stdClass).

So, if there is no "where" statement in the query, I don't want to retrieve any information with $this->db->get(). What I'm looking for is something like

if( ! empty($this->db->where_clauses()))
    $this->db->get('mytable');

Is there something like that?

Thanks.

mysql codeigniter activerecord