Mysql and php

Source: Internet
Author: User
In mysqli, I represents improved. The general call process is: spanstylefont-size: 18px ;. span .. $ dbmysql_connect (...) ordie (connectingerror ...); connect to the database; $ queryselectnamefromuserslimit1; assemble the query string; $ resultmysqli_query ($ db, $ query) ordie (quer

In mysqli, I represents improved. The general call process is: span style = font-size: 18px ;. /span .. $ db = mysql_connect (...) or die (connecting error ...); // connect to the database; $ query = select name from users limit 1; // assemble the query string; $ result = mysqli_query ($ db, $ query) or die (quer

I in mysqli represents improved
General call process:

... $ Db = mysql_connect (...) or die ("connecting error... "); // connect to the database; $ query =" select name from users limit 1 "; // assemble the query string; $ result = mysqli_query ($ db, $ query) or die ("querying error... "); // execute the query; $ row = mysqli_fetch_array ($ result); // obtain the query result $ user_name = $ row ['name']; mysqli_close ($ db ); // close the connection ....


When developing a project, write a Mysqls encapsulation class, which encapsulates various methods, including construction and other basic methods. The call may be like this:

...$ms = new Mysqls;$sql  ="select name from users limit 1";$data = $ms->getRow($sql);if(!$data){    $user_name = $data['name'];}...


Retrieve multiple entries
While ($ row = mysqli_fetch_array ($ result ))...
Foreach ($ data as $ m )...



In the command line, run the USE command before using the database (not required by phpMyAdmin)
DESCRIBE command in the command line
Avoid using * as much as possible and use fields instead.
Try to add limit to each statement
Do not use connection
Read more mysql optimization manual ......

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.