php 中 mysqli 是個(gè)類,這個(gè)類的函數(shù)(方法)有:
成都創(chuàng)新互聯(lián)專注于企業(yè)網(wǎng)絡(luò)營銷推廣、網(wǎng)站重做改版、柯橋網(wǎng)站定制設(shè)計(jì)、自適應(yīng)品牌網(wǎng)站建設(shè)、H5場景定制、成都商城網(wǎng)站開發(fā)、集團(tuán)公司官網(wǎng)建設(shè)、外貿(mào)網(wǎng)站建設(shè)、高端網(wǎng)站制作、響應(yīng)式網(wǎng)頁設(shè)計(jì)等建站業(yè)務(wù),價(jià)格優(yōu)惠性價(jià)比高,為柯橋等各大城市提供網(wǎng)站開發(fā)制作服務(wù)。
mysqli::$affected_rows — Gets the number of affected rows in a previous MySQL operation
mysqli::autocommit — 打開或關(guān)閉本次數(shù)據(jù)庫連接的自動(dòng)命令提交事務(wù)模式
mysqli::begin_transaction — Starts a transaction
mysqli::change_user — Changes the user of the specified database connection
mysqli::character_set_name — 返回當(dāng)前數(shù)據(jù)庫連接的默認(rèn)字符編碼
mysqli::$client_info — Get MySQL client info
mysqli::$client_version — Returns the MySQL client version as a string
mysqli::close — 關(guān)閉先前打開的數(shù)據(jù)庫連接
mysqli::commit — 提交一個(gè)事務(wù)
mysqli::$connect_errno — Returns the error code from last connect call
mysqli::$connect_error — Returns a string description of the last connect error
mysqli::__construct — Open a new connection to the MySQL server
mysqli::debug — Performs debugging operations
mysqli::dump_debug_info — 將調(diào)試信息輸出到日志
mysqli::errno — 返回最近函數(shù)調(diào)用的錯(cuò)誤代碼
mysqli::$error_list — Returns a list of errors from the last command executed
mysqli::$error — Returns a string description of the last error
mysqli::$field_count — Returns the number of columns for the most recent query
mysqli::get_charset — Returns a character set object
mysqli::get_client_info — Get MySQL client info
mysqli_get_client_stats — Returns client per-process statistics
mysqli_get_client_version — 作為一個(gè)整數(shù)返回MySQL客戶端的版本
mysqli::get_connection_stats — Returns statistics about the client connection
mysqli::$host_info — 返回一個(gè)表述使用的連接類型的字符串
mysqli::$protocol_version — 返回MySQL使用的協(xié)議版本號(hào)
mysqli::$server_info — 返回MySQL服務(wù)器的版本號(hào)
mysqli::$server_version — 作為一個(gè)整數(shù)返回MySQL服務(wù)器的版本
mysqli::get_warnings — Get result of SHOW WARNINGS
mysqli::$info — Retrieves information about the most recently executed query
mysqli::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 query
mysqli::kill — Asks the server to kill a MySQL thread
mysqli::more_results — Check if there are any more query results from a multi query
mysqli::multi_query — Performs a query on the database
mysqli::next_result — Prepare next result from multi_query
mysqli::options — Set options
mysqli::ping — Pings a server connection, or tries to reconnect if the connection has gone down
mysqli::poll — Poll connections
mysqli::prepare — Prepare an SQL statement for execution
mysqli::query — 對(duì)數(shù)據(jù)庫執(zhí)行一次查詢
mysqli::real_connect — 建立一個(gè) MySQL 服務(wù)器連接
mysqli::real_escape_string — Escapes special characters in a string for use in an SQL statement, taking into account the current charset of the connection
mysqli::real_query — 執(zhí)行一個(gè)mysql查詢
mysqli::reap_async_query — Get result from async query
mysqli::refresh — Refreshes
mysqli::release_savepoint — Removes the named savepoint from the set of savepoints of the current transaction
mysqli::rollback — 回退當(dāng)前事務(wù)
mysqli::rpl_query_type — Returns RPL query type
mysqli::savepoint — Set a named transaction savepoint
mysqli::select_db — 選擇用于數(shù)據(jù)庫查詢的默認(rèn)數(shù)據(jù)庫
mysqli::send_query — 發(fā)送請(qǐng)求并返回結(jié)果
mysqli::set_charset — 設(shè)置默認(rèn)字符編碼
mysqli::set_local_infile_default — Unsets user defined handler for load local infile command
mysqli::set_local_infile_handler — Set callback function for LOAD DATA LOCAL INFILE command
mysqli::$sqlstate — Returns the SQLSTATE error from previous MySQL operation
mysqli::ssl_set — Used for establishing secure connections using SSL
mysqli::stat — Gets the current system status
mysqli::stmt_init — 初始化一條語句并返回一個(gè)用于mysqli_stmt_prepare(調(diào)用)的對(duì)象
mysqli::store_result — Transfers a result set from the last query
mysqli::$thread_id — Returns the thread ID for the current connection
mysqli::thread_safe — 返回是否是線程安全的
mysqli::use_result — Initiate a result set retrieval
mysqli::$warning_count — Returns the number of warnings from the last query for the given link
以上函數(shù)清單直接來自 網(wǎng)站。你可以進(jìn)入該網(wǎng)站參看。
常用函數(shù)比較多
如:字符串處理函數(shù),數(shù)組函數(shù),日期函數(shù),MySQL函數(shù),文件系統(tǒng)函數(shù),GD函數(shù)庫等
1、PHP獲取顯示數(shù)據(jù)庫數(shù)據(jù)函數(shù)之 mysql_result()
mixed mysql_result(resource result_set, int row [,mixed field])
從result_set 的指定row 中獲取一個(gè)field 的數(shù)據(jù). 簡單但是效率低.
舉例:
$link1?=?@mysql_connect("server1",?
"webuser",?"password")?
or?die("Could?not?connect?
to?mysql?server!");
@mysql_select_db("company")?
or?die("Could?not?select?database!");
$query?=?"select?id,?name?
from?product?order?by?name";?
$result?=?mysql_query($query);
$id?=?mysql_result($result,?0,?"id");
$name?=?mysql_result($result,?0,?"name");
mysql_close();
注意,上述代碼只是輸出結(jié)果集中的第一條數(shù)據(jù)的字段值,如果要輸出所有記錄,需要循環(huán)處理.
for?($i?=?0;?$i?=?mysql_num_rows($result);?$i++)
{
$id?=?mysql_result($result,?0,?"id");
$name?=?mysql_result($result,?0,?"name");
echo?"Product:?$name?($id)";
}
注意,如果查詢字段名是別名,則mysql_result中就使用別名.
2、PHP獲取顯示數(shù)據(jù)庫數(shù)據(jù)函數(shù)之mysql_fetch_row()
array mysql_fetch_row(resource result_set)
從result_set中獲取整行,把數(shù)據(jù)放入數(shù)組中.
舉例(注意和list 的巧妙配合):
$query?=?"select?id,?
name?from?product?order?by?name";?
$result?=?mysql_query($query);
while(list($id,?$name)?
=?mysql_fetch_row($result))?{
echo?"Product:?$name?($id)";
}
3、PHP獲取顯示數(shù)據(jù)庫數(shù)據(jù)函數(shù)之mysql_fetch_array()
array mysql_fetch_array(resource result_set [,int result_type])
mysql_fetch_row()的增強(qiáng)版.
將result_set的每一行獲取為一個(gè)關(guān)聯(lián)數(shù)組或/和數(shù)值索引數(shù)組.
默認(rèn)獲取兩種數(shù)組,result_type可以設(shè)置:
MYSQL_ASSOC:返回關(guān)聯(lián)數(shù)組,字段名=字段值?
MYSQL_NUM:返回?cái)?shù)值索引數(shù)組.
MYSQL_BOTH:獲取兩種數(shù)組.因此每個(gè)字段可以按索引偏移引用,也可以按字段名引用.
舉例:
$query?=?"select?id,
name?from?product?order?by?name";
$result?=?mysql_query($query);
while($row?=?mysql_fetch_array
($result,?MYSQL_BOTH))?{?
$name?=?$row['name'];
//或者?$name?=?$row[1];
$name?=?$row['id'];
//或者?$name?=?$row[0];
echo?"Product:?$name?($id)";
}
4、PHP獲取顯示數(shù)據(jù)庫數(shù)據(jù)函數(shù)之mysql_fetch_assoc()
array mysql_fetch_assoc(resource result_set)
相當(dāng)于 mysql_fetch_array($result, MYSQL_ASSOC)
5、PHP獲取顯示數(shù)據(jù)庫數(shù)據(jù)函數(shù)之mysql_fetch_object()
object mysql_fetch_object(resource result_set)?
和mysql_fetch_array()功能一樣,不過返回的不是數(shù)組,而是一個(gè)對(duì)象.
舉例:
$query?=?"select?id,?name?
from?product?order?by?name";
$result?=?mysql_query($query);?
while($row?=?mysql_fetch_object
($result))?{
$name?=?$row-name;
$name?=?$row-id;
echo?"Product:?$name?($id)";
}
以上這些函數(shù)就是PHP獲取顯示數(shù)據(jù)庫數(shù)據(jù)函數(shù)的全部總結(jié)。
本文標(biāo)題:php數(shù)據(jù)庫包含的函數(shù),php選擇數(shù)據(jù)庫的函數(shù)
網(wǎng)站網(wǎng)址:http://jinyejixie.com/article0/hsicio.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供App設(shè)計(jì)、品牌網(wǎng)站建設(shè)、面包屑導(dǎo)航、外貿(mào)網(wǎng)站建設(shè)、用戶體驗(yàn)、企業(yè)網(wǎng)站制作
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)