问题
For example, if ı have lines like this:
$this->db->where("blabla",$blala);
And following this line, I decided not to use this where clause (in runtime) and start doing a query from scratch. How can I disregard this where clause in active record?
回答1:
Maybe you can try
$this->db->_reset_select();
回答2:
You can't.
This is a logical problem which you have to make sense of.
Instead of saying
$this->db->where('blabla', $blala);
if($dont_use_where_clause) {
//something to ignore the where cause which CI doesn't provides anyway
}
That's like starting your car and trying to get back the fuel you used to start it with.
You would have to do something more logical like this:
if(!$dont_use_where_clause) {
$this->db->where('blabla', $blala);
}
This makes sense, because it's the logical way of doing those things. That's like saying 'if I don't want to use fuel, don't start the car'. Get it?
来源:https://stackoverflow.com/questions/8093370/restarting-active-query-in-codeigniter