PHP functions for MySQL operations

Source: Internet
Author: User

(1) mysql_connect (host, user name, password );
Returns a connection number.
Note: The passwords of mysql users can change with the IP address of the user's machine.
In addition, mSQL does not have a user name mechanism, so msql_connect only needs one host parameter.
The host can be an IP address or domain name.
(2) mysql_create_db (Database Name );
(3) mysql_select_db (Database Name, connection number );
Connect to a database.
(4) mysql_query (SQL statement, connection number );
If the SQL statement is select, a result number is returned. Otherwise, the returned value can be ignored.
If it fails, false is returned.
(5) mysql_fetch_array (result number );
Retrieves the next row and returns an array. It can be accessed with a numerical subscript (the first field is a subscript ).
0). You can also use the string subscript to access the table (that is, use the field names ).
If the last row is obtained, false is returned.
(6) mysql_fetch_field (result number, [field serial number]);
If there is no field serial number, take the next field.
Return a hash table marked:
Name, table, max_length, not_null, primary_key, unique_key,
Multiple_key, numeric, blob, type, unsigned, zerofill
The meanings of each sub-mark should be clear.
(7) mysql_num_rows (result number); mysql_num_fields (result number );
(8) mysql_free_result (result number );
(9) mysql_list_dbs (); mysql_list_tables (Database Name );
(10) mysql_close (connection number );
(11) mysql_pconnect (host, user name, password );
(12) mysql_select_db (Database Name, connection number );
Connect to a database.
Similar to mysql_connect, but a "permanent connection" is established, and the connection will never be established.
Close, even if mysql_close function or program execution is completed, it is not closed. The next attempt to create
When a permanent connection is established, if a permanent connection already exists in the system, the connection number is directly returned.
Do not recreate.

Related Article

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.