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 "); |