About the differences between MySQL and mysqli in Phpcms

Source: Internet
Author: User

Using PHPCMS to develop a small module of exam results query, with the PHPCMS version of the previous download on the computer for the framework development, all smooth. Want to download a new version, and later also avoid the trouble of upgrading. Then, the download is good, and then the module directory, model database connection files, templates and configuration files are copied.

However, the problem has arisen!

...... Debugging for a few hours, in the old and new version of the switch several times, and finally found that the PHPCMS version caused the problem, I le a go!

Using exit () to locate, continue the study, found the problem in the following lines of code:

$result = $this->db->query ($sql);

while ($row =mysql_fetch_row ($result)) {

echo $row [0]. ' <br/> ';

}

These lines of code are indifferent and ineffective ... So, again toss ..., with GetType ($result) detected $result as the object, what object? Don't know, messy ...

Thought of the Var_dump () function.

After entering Var_dump ($result), an object (Mysqli_result) appears. It is indeed a connection resource object, but not a MySQL connection, but a mysqli connection.

Search using the Text Search tool to find the database configuration file database.php inside is such "' type ' = ' mysqli ',";

This is the crux of the problem, change the mysqli to MySQL, everything is normal. But certainly can't change back, so Baidu Mysqli.

It turns out that MySQL (process mode) and Mysqli (object mode) use query queries, but the functions that read row data are different.

MySQL (process mode) with $row = Mysql_fetch_row ($result) Such a way (originally used)

and Mysqli (object mode) with $row = $result, Fetch_row ();

Change it, everything is fine!

About the differences between MySQL and mysqli in Phpcms

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.