PHP controls MySQL functions

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(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. you can use the number subscript to visit (the first field is the subscript ).

0), you can also use the string subscript to visit (that is, the names of each field in the application ).

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.

Closed, even if the mysql_close function or program is completed, it is not closed. The next attempt to create

If a permanent connection exists in the system, the system returns the connection number and

Do not recreate.

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.