我有以下mysql查询.你能告诉我如何用Codeigniter的方式编写相同的查询吗?
SELECT * FROM myTable
WHERE trans_id IN ( SELECT trans_id FROM myTable WHERE code='B')
AND code!='B'
Run Code Online (Sandbox Code Playgroud) 看起来_compile_select已弃用,get_compiled_select不会添加到2.1.0.还有其他类似的功能吗?而且我很好奇.是否有任何特殊原因不添加get_compiled_select()到Active Record并删除_compile_select?
问题很简单,必须讨论很多次,但是我仍然无法获得$ this-> db-> last_query();的结果。
$this->db->select('count(*) as totalverified,res_sales.upduser, employee.name');
$this->db->from('res_sales');
$this->db->join('employee','employee.user_id = res_sales.upduser');
$this->db->where('date>=', $fromdate);
$this->db->where('date<=', $todate);
$this->db->where('verificationnumber<>', '');
$this->db->where('verificationnumber<>', NULL);
$this->db->group_by('res_sales.upduser');
$this->db->group_by('employee.name');
$q = $this->db->get();
$str = $this->db->last_query();
print_r($str);
if ($q->num_rows() > 0)
{
return $q->row();
}
return FALSE;
Run Code Online (Sandbox Code Playgroud)
上面是我的模型函数中的代码。我无法获得预期的结果,想要查看后端正在运行的查询。
谢谢。丹麦文