PHP的mysqli_stmt_init()函數(shù)講解
PHP mysqli_stmt_init() 函數(shù)
初始化聲明并返回 mysqli_stmt_prepare() 使用的對(duì)象:
<?php // 假定數(shù)據(jù)庫用戶名:root,密碼:123456,數(shù)據(jù)庫:codingdict $con=mysqli_connect("localhost","root","123456","codingdict"); if (mysqli_connect_errno($con)) { echo "連接 MySQL 失敗: " . mysqli_connect_error(); } // 修改數(shù)據(jù)庫連接字符集為 utf8 mysqli_set_charset($con,"utf8"); $country="CN"; // 創(chuàng)建預(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 國家的網(wǎng)站為:%s",$country,$name); // 關(guān)閉預(yù)處理語句 mysqli_stmt_close($stmt); } mysqli_close($con); ?>
定義和用法
mysqli_stmt_init()
函數(shù)初始化聲明并返回 mysqli_stmt_prepare() 使用的對(duì)象。
總結(jié)
以上就是這篇文章的全部內(nèi)容了,希望本文的內(nèi)容對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,謝謝大家對(duì)腳本之家的支持。如果你想了解更多相關(guān)內(nèi)容請(qǐng)查看下面相關(guān)鏈接
相關(guān)文章
PHP個(gè)人網(wǎng)站架設(shè)連環(huán)講(二)
PHP個(gè)人網(wǎng)站架設(shè)連環(huán)講(二)...2006-10-10一個(gè)簡單的自動(dòng)發(fā)送郵件系統(tǒng)(三)
一個(gè)簡單的自動(dòng)發(fā)送郵件系統(tǒng)(三)...2006-10-10PHP和Mysqlweb應(yīng)用開發(fā)核心技術(shù) 第1部分 Php基礎(chǔ)-1 開始了解php
PHP和Mysqlweb應(yīng)用開發(fā)核心技術(shù)-第1部分 Php基礎(chǔ)-1開始了解php,想學(xué)習(xí)php的朋友可以看下,比較基礎(chǔ)的知識(shí)。2011-07-07