无法从$ this-> db-> last_query();获取结果点火器 [英] Can't get result from $this->db->last_query(); codeigniter

查看:98
本文介绍了无法从$ this-> db-> last_query();获取结果点火器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问起来很简单,必须多次讨论,但是我仍然无法获得$ this-> db-> last_query();的结果。

Quite a simple thing to ask and must be discussed many times, but I still not able to get the result of $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;

以上是我模型函数中的代码。我无法获得预期的结果,想要查看后端正在运行的查询。

Above is the code in my model function. I am not able to get the result as expected to want to see what the query is being run at backend.

谢谢。
丹麦语

Thanks. Danish

推荐答案

我发现了问题所在。我必须在查询上方写一条语句,即:

I figured out the problem. I have to write a statement just above my query i.e:

$this->db->save_queries = TRUE;

在此之后编写您的查询,然后再编写$ this-> db-> last_query();它现在显示最后一个查询。

After this write your query and than write $this->db->last_query(); it is showing the last query now.

示例:

$this->db->save_queries = TRUE;
$str = $this->db->last_query();
echo $str;

干杯。

这篇关于无法从$ this-&gt; db-&gt; last_query();获取结果点火器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆