Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/252.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/66.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php codeigniter ActiveRecord方法转换为查询_Php_Mysql_Codeigniter_Activerecord - Fatal编程技术网

Php codeigniter ActiveRecord方法转换为查询

Php codeigniter ActiveRecord方法转换为查询,php,mysql,codeigniter,activerecord,Php,Mysql,Codeigniter,Activerecord,是否有任何在线转换器可以将活动记录方法转换为原始sql查询?例如,我有以下方法: $this->db->select('id'); $this->db->from('choices'); $this->db->where('quest_no', $quest_no); $this->db->where('is_correct', '1'); $query = $this->db->get(); 我想把它转换成 SELE

是否有任何在线转换器可以将活动记录方法转换为原始sql查询?例如,我有以下方法:

$this->db->select('id');
$this->db->from('choices');
$this->db->where('quest_no', $quest_no);
$this->db->where('is_correct', '1');        
$query = $this->db->get();
我想把它转换成

SELECT id FROM choices WHERE quest_no = $quest_no AND is_correct = 1 

为了加快速度和快速理解,您需要使用codeigniter的
last\u query()
函数查看标准查询

该函数在
get()函数之后使用,如下所示:

$this->db->select('id');
$this->db->from('choices');
$this->db->where('quest_no', $quest_no);
$this->db->where('is_correct', '1');        
$query = $this->db->get();
echo $this->db->last_query(); exit;

否。没有网站/应用程序将CodeIgniter活动记录代码转换为原始查询。您需要使用
last\u query()
来获取您执行的最后一个原始查询。反之亦然,从原始sql到CodeIgniter活动记录代码执行查询后,您还可以使用
$this->db->last_query()以了解实际查询