爵士执行SQL操作,对于这种特殊情况下
我面临的一个问题,它如下所示: 我想执行若对$输出opertion这个 - > DB->选择(“*” ) - >从( '表');只有当COND1满足
$result = $this->db->select('*')->from('table');
if(cond1)
{
I want to perform $result->where(); operation
}
是否有可能,我还等什么是确切的语法做
爵士执行SQL操作,对于这种特殊情况下
我面临的一个问题,它如下所示: 我想执行若对$输出opertion这个 - > DB->选择(“*” ) - >从( '表');只有当COND1满足
$result = $this->db->select('*')->from('table');
if(cond1)
{
I want to perform $result->where(); operation
}
是否有可能,我还等什么是确切的语法做
尝试这样的事:
$this->db->select('*');
$this->db->from('table');
if ($cond1)
$this->db->where(...)
$query = $this->db->get();
$con1
是应该是一个变量,它应该有一个值或Null。 $con1
就像一个布尔值1或0。如果1(真)发生,它将执行if块,否则它将执行else块。
看起来像你想运行两个不同的查询。假设$cond1
不依赖于$result
(在这种情况下,所有的赌注都关闭),你可以这样做
if(cond1)
$result = $this->db->select('*')->from('table')->where(...);
else
$result = $this->db->select('*')->from('table');
像我希望执行的操作,只有当其中某一condtion我没有得到你的问题 – underscore
其满足 –