CodeIgniter Active Record: Debugging without running SQL

I'm fairly new to Code Igniter, and I'm using Active Record for all the queries in a new project.

Is there a way to output the SQL statement without actually running it.

The function i've created has quite a few statements in it, selects, deletes and updates, and I want to make sure they are correct before running them in a test environment as they have a lot of Ifs and cases around them to build up the queries.

So in short, I just want it to echo the statement, but not run it.

Thanks in advance! :)


Take a look at the insert_string() and update_string() methods listed in the Database Query Helper section of the user guide.

For select you'll need to run $this->db->last_query() after you've run the command, but SELECT is non-destructive so who cares.


Take a look at this answer of mine.
How can I rewrite this SQL into CodeIgniter's Active Records?

In this if you use $this->db->_compile_select() and then echo it it will display the query without running.

链接地址: http://www.djcxy.com/p/43774.html

上一篇: Codeigniter Active记录复杂的查询

下一篇: CodeIgniter Active Record:在不运行SQL的情况下进行调试