In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
The main content of this article is "introduction to the steps of php operating mysql". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn the "introduction to the steps of php operating mysql".
Php operation mysql steps:
1.$connect=mysql_connect ('localhost','root','123456') or die (' database connection failed.' Mysql_error (); link mysql.
2.mysql_select_db ('database',$connect) selects the linked database.
3.mysql_query ('Set names gb2312'); $sql = "select * from blog_article"; prepare the data to query.
4.$datas = mysql_query ($sql); execute the sql query.
5.$data = mysql_fetch_assoc ($datas) gets a piece of data cached in memory from the query.
6.print_r ($data)
Similarity: all three functions return a row of data queried in the database (to put it more clearly, a piece of data).
Difference: mysql_fetch_assoc () uses the corresponding field name in the database as the key value (that is, array subscript)
For example, filed ['id'] = 1
Mysql_fetch_row () uses automatically generated numbers (generated in turn from 0) as the key value (that is, array subscript)
For example, filed [0] = 1
Mysql_fetch_array () uses automatically generated numbers (generated sequentially from 0) as the key value (that is, array subscript), and it also generates the corresponding field name in the database as the key value (that is, array subscript).
Such as:
Filed [0] = 1 filed ['id'] = 1; that is, mysql_fetch_array () combines the results of the mysql_fetch_assoc () and mysql_fetch_row () queries into one.
Mysql_fetch_object () is similar to mysql_fetch_assoc (). It's just that mysql_fetch_assoc () returns an array. Mysql_fetch_object () returns an object object.
Mysql_insert_id () gets the ID generated by the previous INSERT operation.
The mysql_result () function returns the value of a field in the result set.
The mysql_num_fields () function returns the number of fields in the result set.
Mysql_affected_rows (); returns the number of rows of records affected by the previous MySQL operation.
Mysql_num_rows (mysql_query ($sql)) gets the number of rows in the result set.
The mysql_pconnect () function opens a persistent connection to the MySQL server.
Mysql_pconnect () and mysql_connect () are very similar, but have two main differences:
1. When connecting, this function will first try to find a (persistent) connection that has been opened on the same host with the same user name and password, and if found, return this connection ID without opening a new connection.
two。 Second, the connection to the SQL server will not be closed after the script is executed, and the connection will remain open for later use (mysql_close () will not close the connection established by mysql_pconnect ()).
Mysql_data_seek (mysql_query ($sql), 8); get Article 8 data in the result set. (mysql_num_rows (mysql_query ($sql)) and mysql_data_seek (mysql_query ($sql), 8) are not available on mysql_unbuffered_query ($sql). )
Mysql_unbuffered_query ($sql) is similar to mysql_query ($sql), but
Mysql_unbuffered_query ($sql) is not cached. Mysql_query ($sql) caches the results of the query.
Mysql_close (); closes the most recent link to mysql.
Mysql_field_flags (mysql_query ($sql), 6) returns the table attribute output of the sixth field, such as: not_null primary_key auto_increment.
Mysql_fetch_lengths (mysql_query ($sql)) returns the length of each field for all fields of the data. An array of numbers is returned.
Mysql_field_name (mysql_query ($sql), 3) returns the field name of the third field.
Mysql_field_table (mysql_query ($sql), 0) returns the name of the table where the specified field is located.
The mysql_free_result (mysql_query ($sql)) function frees up the result memory.
The mysql_get_client_info () function returns MySQL client information.
Mysql_get_host_info () gets the MySQL host information.
At this point, I believe you have a deeper understanding of the "introduction to the steps of php operation of mysql". You might as well come to the actual operation. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.