Restarting active query in codeigniter

◇◆丶佛笑我妖孽 提交于 2019-12-25 08:22:47

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!