Phpmysqli class demo-php Tutorial

Source: Internet
Author: User
Example of phpmysqli class
I would like to share an example of using mysqli class in php with a description of the methods in mysqli class. it is very comprehensive. if you have any need, please refer to it.

The php code for calling the mysqli class is as follows:

     Set_charset ("utf8"); $ query = "SELECT * from part"; if ($ result = $ db-> query ($ query )) {while ($ row = $ result-> fetch_assoc () {printf ("% s (% s) \ n", $ row ['id'], $ row ['CN _ name']) ;}$ result-> close () ;}$ db-> close (); // mysqli class instance?>

Description of the methods in the mysqli class:

Mysqli_affected_rows-returns the number of rows affected by a MySQL operation mysqli_autocommit-enable or disable autocommit database modification mysqli_bind_param-alias commit () mysqli_bind_result () mysqli_change_user-change the user mysqli_character_set_name of the specified database connection-return the default character set mysqli_client_encoding-alias mysqli_character_set_name () of the database connection () mysqli_close-close mysqli_commit of the currently open database connection-current transaction-return error code mysqli_connect_error of the last operation-return error string description mysqli_connect-open a new connection to MySQL server mysqli_data_seek -In the current record result set, move any row pointer mysqli_debug-debug slave-disable reading master-to-slave-disable RPL parsing mysqli_dump_debug_info-dump debugging information Log mysqli_embedded_connect-open a connection to the embedded MySQL server callback-enable content parsing by the primary handler-enable RPL mysqli_errno-return error code recent function call mysqli_error-return a string that describes the past error mysqli_escape_string-alias mysqli_real_escape_string () mysqli_execute-alias mysqli_stmt_execute () mysqli_fetch_array-get a row from the result set as join, number array, or both apply mysqli_fetch_assoc-get a row from the result set as the correlated array-get the metadata in a single field mysqli_fetch_field-return the result set mysqli_fetch_fields in the next field-return the results of an array object representing the field set response-return the result set of the current row of the length column mysqli_fetch_object-return the result set of the current row as an object mysqli_fetch_row-get a row as an enumeration array mysqli_fetch-alias mysqli_stmt_fetch () mysqli_field_count-number of returned columns recent query mysqli_field_seek-set as result pointer to specified field offset mysqli_field_tell-get result Pointer of current field offset mysqli_free_result-release memory and result handler-return MySQL client version as one string mysqli_get_client_version-obtain MySQL client information mysqli_get_host_info-return the connection type represented by a string using mysqli_get_metadata-alias mysqli_stmt_result_metadata () mysqli_get_proto_info-MySQL of The Returned version uses the mysqli_get_server_info-MySQL server of the returned version mysqli_get_server_version-the MySQL server of the returned version is used as an integer mysqli_info-to retrieve information, the latest query mysqli_init-initializes MySQLi and returns a resource using mysqli_real_connect () mysqli_insert_id-return the automatically generated number and use the final query mysqli_kill-the server is required to kill a MySQL thread mysqli_master_query-the force execution query is always in the master/slave setting mysqli_more_results-check whether there is result: one multi-query mysqli_multi_query-execute the query database mysqli_next_result-prepare the results for next year. multi_query results-result obtained in several fields-result obtained result rows result mysqli_options-set the option mysqli_param_count-alias () mysqli_ping-Ping a server connection, or try to reconnect, if mysqli_prepare has been dropped-prepare an SQL statement to execute mysqli_query-execute the query database mysqli_real_connect-open a string connected to the MySQL server mysqli_real_escape_string-escape special characters for SQL statements, take into account the connection of the current character set mysqli_real_query-execute an SQL query mysqli_report-enable or disable the internal report function mysqli_rollback-roll back the current transaction commit-check whether RPL resolution is enabled mysqli_rpl_probe- returns the RPL query type mysqli_select_db-the default database selected to query mysqli_send_long_data-alias mysqli_stmt_send_long_data () mysqli_send_query-send query and return mysqli_server_end-shut down embedded server mysqli_server_init-initialize default client character set mysqli_set_opt-alias mysqli_options () of the embedded server mysqli_set_charset () mysqli_sqlstate-SQLSTATE error returned from mysqli_ssl_set in a MySQL operation-used to establish a secure connection using SSL mysqli_stat-retrieve the current system status mysqli_stmt_affected_rows-returned Total number column change, delete or insert the final statement mysqli_stmt_bind_param-bind a variable declaration as the result stored in the Declaration of the parameter mysqli_stmt_bind_result-bind a variable mysqli_stmt_close-close a declaration prepare-find any the row declaration result set response-the latest declaration of the returned error code calls mysqli_stmt_error-returns a string description and the final declaration error mysqli_stmt_execute-executes a prepared statement to query mysqli_stmt_fetch-gets the result to include it constraint variable mysqli_stmt_free_result-declaration of saving-memory-free results for processing mysqli_stmt_init-initialization statement, and returns an object, used to restore rows-returned rows report result set mysqli_stmt_param_count-returns some declarations given parameters mysqli_stmt_prepare-prepare an SQL statement to execute mysqli_stmt_reset-reset a declaration of Restore-returned result set metadata written statement handler-send data block mysqli_stmt_sqlstate-return SQLSTATE error action from previous statement mysqli_stmt_store_result-transfer result set by one statement mysqli_store_result-transfer result set final query mysqli_thread_id-return thread the ID is mysqli_thread_safe for the current connection. the returned result is thread-safe or not mysqli_use_result.-create the search result set mysqli_warning_count. the returned result is a warning.

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.