我正在使用函数来设置整个sql查询。 这个函数被其他两个用来获取sql,然后根据需要使用它。清除CodeIgniter中的SELECT字段
现在,我想要另一个函数来执行相同的查询,但我不需要以前的函数需要的所有字段。所以,我想知道是否有方法在设置后替换查询的SELECT部分。
伪代码:
function sql(){
$this->db->select('*');
$this->db->from('table');
}
function defaultSql(){
$this->sql();
$this->get();
}
function notAllFields(){
$this->sql();
// This is the solution I'm looking for. It should clear the select
$this->db->clearSelect();
// I define a different select
$this->db->select('field');
$this->get();
}
提前感谢!
请注意,我正在寻找一种解决方案,实际上可以清除已设置的选择。我的源代码比示例复杂得多,所以我不想将任何参数传递给sql函数。 ;) – j4nSolo 2013-05-13 08:40:34