php 中 mysqli 是個類,這個類的函數(方法)有:

創新互聯2013年至今,是專業互聯網技術服務公司,擁有項目網站制作、做網站網站策劃,項目實施與項目整合能力。我們以讓每一個夢想脫穎而出為使命,1280元鼓樓做網站,已為上家服務,為鼓樓各地企業和個人服務,聯系電話:13518219792
mysqli::$affected_rows — Gets the number of affected rows in a previous MySQL operation
mysqli::autocommit — 打開或關閉本次數據庫連接的自動命令提交事務模式
mysqli::begin_transaction — Starts a transaction
mysqli::change_user — Changes the user of the specified database connection
mysqli::character_set_name — 返回當前數據庫連接的默認字符編碼
mysqli::$client_info — Get MySQL client info
mysqli::$client_version — Returns the MySQL client version as a string
mysqli::close — 關閉先前打開的數據庫連接
mysqli::commit — 提交一個事務
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 — 將調試信息輸出到日志
mysqli::errno — 返回最近函數調用的錯誤代碼
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 — 作為一個整數返回MySQL客戶端的版本
mysqli::get_connection_stats — Returns statistics about the client connection
mysqli::$host_info — 返回一個表述使用的連接類型的字符串
mysqli::$protocol_version — 返回MySQL使用的協議版本號
mysqli::$server_info — 返回MySQL服務器的版本號
mysqli::$server_version — 作為一個整數返回MySQL服務器的版本
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 — 對數據庫執行一次查詢
mysqli::real_connect — 建立一個 MySQL 服務器連接
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 — 執行一個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 — 回退當前事務
mysqli::rpl_query_type — Returns RPL query type
mysqli::savepoint — Set a named transaction savepoint
mysqli::select_db — 選擇用于數據庫查詢的默認數據庫
mysqli::send_query — 發送請求并返回結果
mysqli::set_charset — 設置默認字符編碼
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 — 初始化一條語句并返回一個用于mysqli_stmt_prepare(調用)的對象
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
以上函數清單直接來自 網站。你可以進入該網站參看。
1、用navicat新建一個數據庫database1。
2、在database1數據庫中新建一個表table2。
3、在table2中添加新的數據,新建一個名稱為mysql_query的數據庫。
4、在頁面中用mysql_connect 函數與數據庫建立連接。
5、用mysql_select_db函數選擇要查詢的數據庫。
6、添加一個查詢 table2表的查詢語句“$sql=select * from table2“。
7、將查詢語句$sql添加到查詢數據庫函數mysql_query中,返回值賦值給變量query。
8、最后將mysql_query。php文件在瀏覽器中打開,查看查詢到數據庫中的內容的結果。
在使用php session進行數據查詢時主要有3中方法。第一種是使用函數【mysql_connect()】建立和MYSQL數據庫的連接。mysql_connect()是用來建立和MYSQL數據庫的連接,一共有5個參數,一般情況下只使用前3個參數,分別是MySQL服務器地址、用戶名以及密碼。第二種是使用函數【mysql_select_db()】指定要操作的數據庫。mysql_select_db()是用來指定要操作的數據庫。要是需要操作的數據庫還沒有創建,則需要創建數據庫,然后再創建數據庫中的表。第三種是使用函數【mysql_query()】查詢指令。mysql_query()是查詢指令的專用函數,所有的SQL語句都通過它執行,并返回結果集。一般情況下這三種方法是最適用的,希望可以解決你的問題。
1、PHP獲取顯示數據庫數據函數之 mysql_result()
mixed mysql_result(resource result_set, int row [,mixed field])
從result_set 的指定row 中獲取一個field 的數據. 簡單但是效率低.
舉例:
$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();
注意,上述代碼只是輸出結果集中的第一條數據的字段值,如果要輸出所有記錄,需要循環處理.
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獲取顯示數據庫數據函數之mysql_fetch_row()
array mysql_fetch_row(resource result_set)
從result_set中獲取整行,把數據放入數組中.
舉例(注意和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獲取顯示數據庫數據函數之mysql_fetch_array()
array mysql_fetch_array(resource result_set [,int result_type])
mysql_fetch_row()的增強版.
將result_set的每一行獲取為一個關聯數組或/和數值索引數組.
默認獲取兩種數組,result_type可以設置:
MYSQL_ASSOC:返回關聯數組,字段名=字段值?
MYSQL_NUM:返回數值索引數組.
MYSQL_BOTH:獲取兩種數組.因此每個字段可以按索引偏移引用,也可以按字段名引用.
舉例:
$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獲取顯示數據庫數據函數之mysql_fetch_assoc()
array mysql_fetch_assoc(resource result_set)
相當于 mysql_fetch_array($result, MYSQL_ASSOC)
5、PHP獲取顯示數據庫數據函數之mysql_fetch_object()
object mysql_fetch_object(resource result_set)?
和mysql_fetch_array()功能一樣,不過返回的不是數組,而是一個對象.
舉例:
$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)";
}
以上這些函數就是PHP獲取顯示數據庫數據函數的全部總結。
新聞名稱:php數據庫查詢函數 php查詢數據庫內容
文章地址:http://www.yijiale78.com/article0/ddocdio.html
成都網站建設公司_創新互聯,為您提供做網站、品牌網站制作、網站策劃、面包屑導航、企業建站、定制開發
聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯