色综合图-色综合图片-色综合图片二区150p-色综合图区-玖玖国产精品视频-玖玖香蕉视频

您的位置:首頁技術(shù)文章
文章詳情頁

PHP數(shù)據(jù)庫擴展之MySQL增強版擴展MySQLi

瀏覽:2日期:2022-09-15 16:29:29

mysqli擴展允許我們訪問MySQL 4.1及以上版本提供的功能。?

mysqli擴展和持久化連接

mysqli擴展的持久化連接在PHP5.3中被引入。支持已經(jīng)存在于PDO MYSQL 和ext/mysql中。持久化連接背后的思想是客戶端進程和數(shù)據(jù)庫之間的連接可以通過一個客戶端進程來保持重用, 而不是多次的創(chuàng)建和銷毀。這降低了每次需要創(chuàng)建一個新連接的開銷,未使用的連接被緩存起來并且準備隨時被重用。

不像mysql擴展,mysqli沒有提供一個特殊的方法用于打開持久化連接。需要打開一個持久化連接時,你必須在 連接時在主機名前增加p:。

使用持久化連接的問題在于它們可能在客戶端處于不可預知的狀態(tài)。比如,一個表鎖可能在客戶端意外終止之前被激活。 一個新的客戶端進程重用這個持久化連接就會'按照原樣'得到這個連接。這樣,一個新的客戶端進程 為了更好的使用持久化連接,就需要做任何可能的清理工作,這樣就增加了對程序員的負擔。

mysqli擴展的持久化連接提供了內(nèi)建的清理處理代碼。mysqli?所做的清理工作包括:

回滾活動的事務(wù)關(guān)閉并且刪除臨時表對表解鎖、重置會話變量關(guān)閉prepared語句(在PHP中經(jīng)常發(fā)生)關(guān)閉處理程序釋放通過?GET_LOCK()獲得的鎖

這確保了從連接池返回的持久化連接在客戶端進程使用它之前處于干凈的狀態(tài)。

mysqli擴展通過自動的調(diào)用C-API函數(shù)mysql_change_user()?來完成這個清理工作。

自動清理的特性有優(yōu)點也有缺點。優(yōu)點是程序員不再需要擔心附加的清理代碼,因為它們會自動調(diào)用。然而缺點就是 代碼可能會潛在的慢一點,因為每次從連接池返回一個連接都需要執(zhí)行這些清理代碼。

這個自動清理的代碼可以通過在編譯php時定義MYSQLI_NO_CHANGE_USER_ON_PCONNECT?來關(guān)閉。

mysqli擴展在使用Mysql Native Driver或Mysql Client Library(libmysql)時都支持持久化連接。

MySQLi類

代表PHP和Mysql數(shù)據(jù)庫之間的一個連接。

mysqli::$affected_rows?— Gets the number of affected rows in a previous MySQL operationmysqli::autocommit?— 打開或關(guān)閉本次數(shù)據(jù)庫連接的自動命令提交事務(wù)模式mysqli::begin_transaction?— Starts a transactionmysqli::change_user?— Changes the user of the specified database connectionmysqli::character_set_name?— 返回當前數(shù)據(jù)庫連接的默認字符編碼mysqli::$client_info?— Get MySQL client infomysqli::$client_version?— Returns the MySQL client version as a stringmysqli::close?— 關(guān)閉先前打開的數(shù)據(jù)庫連接mysqli::commit?— 提交一個事務(wù)mysqli::$connect_errno?— Returns the error code from last connect callmysqli::$connect_error?— Returns a string description of the last connect errormysqli::__construct?— Open a new connection to the MySQL servermysqli::debug?— Performs debugging operationsmysqli::dump_debug_info?— 將調(diào)試信息輸出到日志mysqli::errno?— 返回最近函數(shù)調(diào)用的錯誤代碼mysqli::$error_list?— Returns a list of errors from the last command executedmysqli::$error?— Returns a string description of the last errormysqli::$field_count?— Returns the number of columns for the most recent querymysqli::get_charset?— Returns a character set objectmysqli::get_client_info?— Get MySQL client infomysqli_get_client_stats?— Returns client per-process statisticsmysqli_get_client_version?— Returns the MySQL client version as an integermysqli::get_connection_stats?— Returns statistics about the client connectionmysqli::$host_info?— Returns a string representing the type of connection usedmysqli::$protocol_version?— Returns the version of the MySQL protocol usedmysqli::$server_info?— Returns the version of the MySQL servermysqli::$server_version?— Returns the version of the MySQL server as an integermysqli::get_warnings?— Get result of SHOW WARNINGSmysqli::$info?— Retrieves information about the most recently executed querymysqli::init?— Initializes MySQLi and returns a resource for use with mysqli_real_connect()mysqli::$insert_id?— Returns the auto generated id used in the last querymysqli::kill?— Asks the server to kill a MySQL threadmysqli::more_results?— Check if there are any more query results from a multi querymysqli::multi_query?— Performs a query on the databasemysqli::next_result?— Prepare next result from multi_querymysqli::options?— Set optionsmysqli::ping?— Pings a server connection, or tries to reconnect if the connection has gone downmysqli::poll?— Poll connectionsmysqli::prepare?— Prepare an SQL statement for executionmysqli::query?— 對數(shù)據(jù)庫執(zhí)行一次查詢mysqli::real_connect?— Opens a connection to a mysql servermysqli::real_escape_string?— Escapes special characters in a string for use in an SQL statement, taking into account the current charset of the connectionmysqli::real_query?— 執(zhí)行一個mysql查詢mysqli::reap_async_query?— Get result from async querymysqli::refresh?— Refreshesmysqli::release_savepoint?— Rolls back a transaction to the named savepointmysqli::rollback?— 回退當前事務(wù)mysqli::rpl_query_type?— Returns RPL query typemysqli::savepoint?— Set a named transaction savepointmysqli::select_db?— 選擇用于數(shù)據(jù)庫查詢的默認數(shù)據(jù)庫mysqli::send_query?— 發(fā)送請求并返回結(jié)果mysqli::set_charset?— 設(shè)置默認字符編碼mysqli::set_local_infile_default?— Unsets user defined handler for load local infile commandmysqli::set_local_infile_handler?— Set callback function for LOAD DATA LOCAL INFILE commandmysqli::$sqlstate?— Returns the SQLSTATE error from previous MySQL operationmysqli::ssl_set?— Used for establishing secure connections using SSLmysqli::stat?— Gets the current system statusmysqli::stmt_init?— 初始化一條語句并返回一個用于mysqli_stmt_prepare(調(diào)用)的對象mysqli::store_result?— Transfers a result set from the last querymysqli::$thread_id?— Returns the thread ID for the current connectionmysqli::thread_safe?— 返回是否是線程安全的mysqli::use_result?— Initiate a result set retrievalmysqli::$warning_count?— Returns the number of warnings from the last query for the given linkMySQLi_STMT類

代表一個prepared語句。

mysqli_stmt::$affected_rows?— Returns the total number of rows changed, deleted, or inserted by the last executed statementmysqli_stmt::attr_get?— Used to get the current value of a statement attributemysqli_stmt::attr_set?— Used to modify the behavior of a prepared statementmysqli_stmt::bind_param?— Binds variables to a prepared statement as parametersmysqli_stmt::bind_result?— Binds variables to a prepared statement for result storagemysqli_stmt::close?— Closes a prepared statementmysqli_stmt::data_seek?— Seeks to an arbitrary row in statement result setmysqli_stmt::$errno?— Returns the error code for the most recent statement callmysqli_stmt::$error_list?— Returns a list of errors from the last statement executedmysqli_stmt::$error?— Returns a string description for last statement errormysqli_stmt::execute?— Executes a prepared Querymysqli_stmt::fetch?— Fetch results from a prepared statement into the bound variablesmysqli_stmt::$field_count?— Returns the number of field in the given statementmysqli_stmt::free_result?— Frees stored result memory for the given statement handlemysqli_stmt::get_result?— Gets a result set from a prepared statementmysqli_stmt::get_warnings?— Get result of SHOW WARNINGSmysqli_stmt::$insert_id?— Get the ID generated from the previous INSERT operationmysqli_stmt::more_results?— Check if there are more query results from a multiple querymysqli_stmt::next_result?— Reads the next result from a multiple querymysqli_stmt::$num_rows?— Return the number of rows in statements result setmysqli_stmt::$param_count?— Returns the number of parameter for the given statementmysqli_stmt::prepare?— Prepare an SQL statement for executionmysqli_stmt::reset?— Resets a prepared statementmysqli_stmt::result_metadata?— Returns result set metadata from a prepared statementmysqli_stmt::send_long_data?— Send data in blocksmysqli_stmt::$sqlstate?— Returns SQLSTATE error from previous statement operationmysqli_stmt::store_result?— Transfers a result set from a prepared statementmysqli_result類

代表從一個數(shù)據(jù)庫查詢中獲取的結(jié)果集

mysqli_result::$current_field?— Get current field offset of a result pointermysqli_result::data_seek?— Adjusts the result pointer to an arbitrary row in the resultmysqli_result::fetch_all?— Fetches all result rows as an associative array, a numeric array, or bothmysqli_result::fetch_array?— Fetch a result row as an associative, a numeric array, or bothmysqli_result::fetch_assoc?— Fetch a result row as an associative arraymysqli_result::fetch_field_direct?— Fetch meta-data for a single fieldmysqli_result::fetch_field?— Returns the next field in the result setmysqli_result::fetch_fields?— Returns an array of objects representing the fields in a result setmysqli_result::fetch_object?— Returns the current row of a result set as an objectmysqli_result::fetch_row?— Get a result row as an enumerated arraymysqli_result::$field_count?— Get the number of fields in a resultmysqli_result::field_seek?— Set result pointer to a specified field offsetmysqli_result::free?— Frees the memory associated with a resultmysqli_result::$lengths?— Returns the lengths of the columns of the current row in the result setmysqli_result::$num_rows?— Gets the number of rows in a resultMySQLi_Driver類

MySQLi 驅(qū)動.

client_info客戶端API頭版本(比如:(string)'5.1.49')

client_version客戶端版本(比如:(int)50149)

driver_versionMysqli驅(qū)動版本(比如:(int)101009)

embedded是否開啟了MySQLi嵌入式支持。

reconnect允許或阻止重連接(查看INI指令中的mysqli.reconnect)

report_mode設(shè)置為MYSQLI_REPORT_OFF,?MYSQLI_REPORT_ALL或者?MYSQLI_REPORT_STRICT?(為錯誤拋出異常,譯注:需要和MYSQLI_REPORT_ERROR聯(lián)合使用),?MYSQLI_REPORT_ERROR?(報告MYSQL錯誤)和?MYSQLI_REPORT_INDEX?(報告索引相關(guān)的錯誤)的任意組合。

mysqli_driver::embedded_server_end?— Stop embedded servermysqli_driver::embedded_server_start?— Initialize and start embedded servermysqli_driver::$report_mode?— Enables or disables internal report functionsMySQLi_Warning類

代表一個Mysql警告。

message消息字符串

sqlstateSQL狀態(tài)

errno錯誤編號

mysqli_warning::__construct?— The __construct purposemysqli_warning::next?— The next purposemysqli_sql_exception類

mysqli異常處理類

mysqli_sql_exception extends RuntimeException { /* 屬性 */ protected string $sqlstate ; /* 繼承的屬性 */ protected string $message ; protected int $code ; protected string $file ; protected int $line ;}別名和過時的Mysqli 函數(shù)mysqli_bind_param?— mysqli_stmt_bind_param的別名mysqli_bind_result?— mysqli_stmt_bind_result的別名mysqli_client_encoding?— mysqli_character_set_name的別名mysqli_connect?— 別名 mysqli::__constructmysqli::disable_reads_from_master?— Disable reads from mastermysqli_disable_rpl_parse?— 禁用RPL解析mysqli_enable_reads_from_master?— 開啟從主機讀取mysqli_enable_rpl_parse?— 開啟RPL解析mysqli_escape_string?— 別名 mysqli_real_escape_stringmysqli_execute?— mysqli_stmt_execute的別名mysqli_fetch?— mysqli_stmt_fetch的別名。mysqli_get_cache_stats?— 返回客戶端Zval緩存統(tǒng)計信息mysqli_get_metadata?— mysqli_stmt_result_metadata的別名mysqli_master_query?— 在主/從機制中強制在主機中執(zhí)行一個查詢mysqli_param_count?— mysqli_stmt_param_count的別名mysqli_report?— 開啟或禁用(Mysql)內(nèi)部(錯誤)報告函數(shù)mysqli_rpl_parse_enabled?— 檢查是否開啟了RPL解析mysqli_rpl_probe?— RPL探測mysqli_send_long_data?— mysqli_stmt_send_long_data的別名mysqli_set_opt?— mysqli_options的別名mysqli_slave_query?— 在主/從機制中強制在從機上執(zhí)行一個查詢

標簽: PHP
相關(guān)文章:
主站蜘蛛池模板: 久久精品夜色国产 | 久久精品九九 | 国产成人免费手机在线观看视频 | 久久国产精品免费网站 | 免费在线成人网 | 亚洲黄色免费观看 | 福利视频黄 | 久久夜夜视频 | 国产在线精品香蕉综合网一区 | 午夜毛片不卡高清免费 | 久久99久久精品久久久久久 | 国产三区视频在线观看 | 欧美日韩视频在线第一区二区三区 | 亚洲国产欧美在线成人aaaa | 手机在线观看黄色网址 | 国产精品视频久久 | 99久久精品无码一区二区毛片 | 久久99综合国产精品亚洲首页 | 在线黄 | 普通话对白国产情侣自啪 | 国产一级毛片大陆 | 亚洲一区二区三区高清视频 | 久久久久久久久久久久久久久久久 | 久久久黄色片 | 日本黄网在线观看 | 国产精品高清视亚洲一区二区 | 高清国产在线播放成人 | 亚洲男人的性天堂 | 玖草在线播放 | 欧美一级亚洲一级 | 亚洲美女爱爱 | 免费观看欧美一级毛片 | 欧美日韩精品一区二区三区视频在线 | 国内精品久久久久久 | 欧美成人性毛片免费版 | 有码在线 | 男人的天堂在线免费视频 | 久久国产视频网站 | 免费一看一级欧美 | 亚洲视频精选 | 特级一级毛片免费看 |