Recently I have been studying php(as the current mainstream development language) and MySQL(the best combination with PHP), and I feel that php(as the current mainstream development language) Language)The functions that interact with MySQL(The best combination with PHP) are all procedural. Of course, there are also MySQL(The best combination with PHP)i After writing too much about extensions, object-oriented, Java and C#, I then started writing PHP (as the current mainstream development language) . I felt a little uncomfortable and felt like I was back to the age of learning C. I learned some functions today and recorded them so that I can refer to them when I forget them in the future.
Description | Function name | Function details | Function description |
Establish a database connection | MySQL(The best combination with PHP)_connect() | resource MySQL(The 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(With PHP) The best combination) Server"); |
Use the connection that must be displayed to close the connection |
Establish a database connection | MySQL(The best combination with PHP)_pconnect() | resource MySQL(The 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"); |
Using this connection function does not require closing the connection explicitly, it is equivalent to using a connection pool |
Close database connection | MySQL(The best combination with PHP)_close() | $conn = @MySQL(The best combination with PHP)_connect("localhost", "username", "password") or die("Cannot connect to MySQL(With PHP The best combination) Server"); @MySQL(The best combination with PHP)_select_db("MyDatabase") or die("This database cannot be selected, or the database is not Exists"); echo "You have connected to the MyDatabase database"; MySQL(The best combination with PHP)_close(); |
|
Select database | MySQL(The best combination with PHP)_select_db() | boolean MySQL(The 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"); |