PHP的mysqli_stmt_init()函數(shù)講解
PHP mysqli_stmt_init() 函數(shù)
初始化聲明并返回 mysqli_stmt_prepare() 使用的對(duì)象:
<?php
// 假定數(shù)據(jù)庫(kù)用戶名:root,密碼:123456,數(shù)據(jù)庫(kù):codingdict
$con=mysqli_connect("localhost","root","123456","codingdict");
if (mysqli_connect_errno($con))
{
echo "連接 MySQL 失敗: " . mysqli_connect_error();
}
// 修改數(shù)據(jù)庫(kù)連接字符集為 utf8
mysqli_set_charset($con,"utf8");
$country="CN";
// 創(chuàng)建預(yù)處理語(yǔ)句
$stmt=mysqli_stmt_init($con);
if (mysqli_stmt_prepare($stmt,"SELECT name FROM websites WHERE country=?"))
{
// 綁定參數(shù)
mysqli_stmt_bind_param($stmt,"s",$country);
// 執(zhí)行查詢
mysqli_stmt_execute($stmt);
// 綁定結(jié)果變量
mysqli_stmt_bind_result($stmt,$name);
// 獲取值
mysqli_stmt_fetch($stmt);
printf("%s 國(guó)家的網(wǎng)站為:%s",$country,$name);
// 關(guān)閉預(yù)處理語(yǔ)句
mysqli_stmt_close($stmt);
}
mysqli_close($con);
?>
定義和用法
mysqli_stmt_init() 函數(shù)初始化聲明并返回 mysqli_stmt_prepare() 使用的對(duì)象。

總結(jié)
以上就是這篇文章的全部?jī)?nèi)容了,希望本文的內(nèi)容對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,謝謝大家對(duì)腳本之家的支持。如果你想了解更多相關(guān)內(nèi)容請(qǐng)查看下面相關(guān)鏈接
相關(guān)文章
PHP4實(shí)際應(yīng)用經(jīng)驗(yàn)篇(1)
PHP4實(shí)際應(yīng)用經(jīng)驗(yàn)篇(1)...2006-10-10
PHP學(xué)習(xí)筆記之二 php入門知識(shí)
PHP學(xué)習(xí)筆記之二 php入門知識(shí)點(diǎn)小結(jié),學(xué)習(xí)php的朋友可以參考下。2011-01-01
通過(guò)對(duì)服務(wù)器端特性的配置加強(qiáng)php的安全
通過(guò)對(duì)服務(wù)器端特性的配置加強(qiáng)php的安全...2006-10-10
PHP 存取 MySQL 數(shù)據(jù)庫(kù)的一個(gè)例子
PHP 存取 MySQL 數(shù)據(jù)庫(kù)的一個(gè)例子...2006-10-10
php imagecreatetruecolor 創(chuàng)建高清和透明圖片代碼小結(jié)
php imagecreatetruecolor 生成圖片示例代碼,需要的朋友可以參考下。2010-05-05
Php+SqlServer實(shí)現(xiàn)分頁(yè)顯示
Php+SqlServer實(shí)現(xiàn)分頁(yè)顯示...2006-10-10

