Notes for learning PHP and MYSQL interactive function tables

Source: Internet
Author: User

Recently, I have been studying php (as the mainstream development language) and MySQL (the best combination with PHP). I feel that php (as the mainstream development language) functions that interact with MySQL (the best combination with PHP) are procedural. Of course, MySQL (the best combination with PHP) I Extension, object-oriented, after writing too much Java and C #, I wrote php again (as the current mainstream development language). Some of them were not suitable and I felt that I had returned to the C era. I learned some functions today and recorded them so that I can refer to them when I forget them later.

Description Letter count Detailed description Description
Establish Database Connection MySQL (best combination with PHP) _ connect () Resource MySQL (best combination with PHP) _ connect ([string hostname [: port] [:/path/to/socket] [, string username] [, string password])
Example: $ conn = @ MySQL (the best combination with PHP) _ connect ("localhost", "username", "password ") or dir ("cannot connect to MySQL (the best combination with PHP) Server ");
Close the connection that must be displayed when this connection is used
Establish Database Connection MySQL (best combination with PHP) _ pconnect () Resource MySQL (best combination with PHP) _ pconnect ([string hostname [: port] [:/path/to/socket] [, string username] [, string password])
Example: $ conn = @ MySQL (the best combination with PHP) _ pconnect ("localhost", "username", "password ") or dir ("cannot connect to MySQL (the best combination with PHP) Server ");
The connection function does not need to be displayed to close the connection. It is equivalent to using the connection pool.
Close database connection MySQL (best combination with PHP) _ close () $ Conn = @ MySQL (the best combination with PHP) _ connect ("localhost", "username", "password ") or die ("cannot connect to MySQL (the best combination with PHP) Server ");
@ MySQL (the best combination with PHP) _ select_db ("MyDatabase") or die ("this database cannot be selected, or the database does not exist ");
Echo "you have connected to MyDatabase ";
MySQL (the best combination with PHP) _ close ();
 
Select Database MySQL (best combination with PHP) _ select_db () Boolean MySQL (best combination with PHP) _ select_db (string db_name [, resource link_id])
$ Conn = @ MySQL (the best combination with PHP) _ connect ("localhost", "username", "password ") or die ("cannot connect to MySQL (the best combination with PHP) Server ");
@ MySQL (the best combination with PHP) _ select_db ("MyDatabase") or die ("this database cannot be selected, or the database does not exist ");

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.