【发布时间】:2011-04-07 23:46:23
【问题描述】:
例如,我想转换这个;
$this->db->get('table');
到这个;
'SELECT * FROM table'
这有什么功能吗?我搜索了 CI 的用户指南,但没有找到任何解决方案。
【问题讨论】:
标签: php activerecord codeigniter
例如,我想转换这个;
$this->db->get('table');
到这个;
'SELECT * FROM table'
这有什么功能吗?我搜索了 CI 的用户指南,但没有找到任何解决方案。
【问题讨论】:
标签: php activerecord codeigniter
您也可以使用$this->db->get_compiled_select()。 get_compiled_select() 和 last_query() 之间的区别在于 get_compiled_select() 给出了即使您不针对数据库运行查询也会生成的查询字符串。
【讨论】:
_compile_select(),你必须在执行查询后使用$this->db->_reset_select();。如果不这样做,CodeIgniter 将不会清除查询,并且以后的所有查询都将不起作用。
_compile_select() 不再工作,因为他们在最新的 CI2 Github 存储库中保护了该功能。我多次使用此功能,现在我被卡住了。也许有解决办法?
get_compiled_select()。 codeigniter.com/nightly_user_guide/database/…
get_compiled_select() 将可用于 codeigniter-3 codeigniter.com/userguide3/database/query_builder.html codeigniter.com/userguide3/changelog.html
试试
echo $this->db->last_query();
在您运行 Active Record Query 之后,它会吐出它为您运行的原始 SQL。我经常使用它。
【讨论】: