PHP operation MySQL function

Source: Internet
Author: User
mysql| function (1) mysql_connect (host, username, password);





returns a connection number.





Note: MySQL user password can vary depending on the user's machine IP address.





In addition, mSQL has no user name mechanism, so msql_connect only needs one host parameter.




The
host can be an IP address or a 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 a SELECT, returns a result number. Otherwise the returned value can be ignored.





returns False if it fails.











(5) mysql_fetch_array (result number);





takes out the next line and returns an array. can be accessed with a digital subscript (the first field is subscript





0), you can also use string subscript access (that is, using each field name).





returns False if the last row has been taken.











(6) Mysql_fetch_field (Result number, [field ordinal]);





If no field number, remove a field.





returns a hash table with the following label:





Name,table,max_length,not_null,primary_key,unique_key,





Multiple_key,numeric,blob,type,unsigned,zerofill





the meaning of each subscript should be more 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);











(a) Mysql_close (connection number);











(one) mysql_pconnect (host, username, password);











() mysql_select_db (database name, connection number);





connect to a database.











is exactly like Mysql_connect, but establishes a "permanent connection" that is never
once established




is closed, even if the Mysql_close function or program is finished. Next attempt to build





when a permanent connection is made, the system returns the connection number directly if it discovers that a permanent connection already exists





is not recreated.











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.