先生,
我遇到了一个问题,如下所示: 我想对 $this->db->select('*')->from('table'); 的输出执行 where 操作仅当 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();
关于php - 针对这种特殊情况执行sql操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17069472/