Phpcms V9 Transformation: Output SQL statement

Source: Internet
Author: User

1, modifying the database driver
Phpcms/libs/classes/mysql.class. PHP Add the following code:
/**
* Last query statement
*/
Private$lastquerysql ="';
Publicfunction Lastsql () {
return$ This->lastquerysql;
}

Modify the Execute method,
$ This->lastqueryid = mysql_query ($sql, $ This->link) or $ This->halt (Mysql_error (), $sql);

Add a row before
$ This->lastquerysql = $sql;

That
Privatefunction Execute ($sql) {
if(!is_resource ($ This->link)) {
$ This->connect ();
}

$ This->lastquerysql = $sql;
$ This->lastqueryid = mysql_query ($sql, $ This->link) or $ This->halt (Mysql_error (), $sql);

$ This->querycount++;
return$ This->lastqueryid;
}

2, modify the Model
Phpcms/libs/classes/model.class. PHP Add a method to
Publicfunction Lastsql () {
return$ This->db->lastsql ();
}

3Call
After the query is completed using a custom model class, the Lastsql () method of the model class is called to
Phpsso MySQL class and model class can be changed without change, under normal circumstances will not be used

Phpcms V9 Transformation: Output SQL statement

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.