Blogger Information
Blog 32
fans 0
comment 0
visits 19600
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
0424
XuanGG的博客
Original
484 people have browsed it

实例

<?php
/**
 * Created by PhpStorm.
 * User: xuan
 * Date: 2018/6/6
 * Time: 11:25
 */
header("Content-type:text/html;charset=utf-8");

require('conf.php');

// 写一条预处理模型
$sql = "select * from user where user_id=?; ";

$id =3;

// 开始预处理
$stmt =mysqli_stmt_init($db);


// 判断预处理 模型语句对或者错

if(mysqli_stmt_prepare($stmt,$sql)){

    @mysqli_stmt_bind_param($stmt,'i',$id);

    if(@mysqli_stmt_execute($stmt)){

    }else{
        echo '没有该记录';
    }
    //获取结果集
    mysqli_stmt_store_result($stmt);
    //绑定结果集
    @mysqli_stmt_bind_result($stmt,$name,$id);


    // 遍历结果集
    if(@mysqli_stmt_num_rows($stmt) > 0){
        while(mysqli_stmt_fetch($stmt)){
            echo "[{$name}] => {$id}]<br>";
        }

    }else{
       echo '没有查询到记录';
    }

}else{
    exit('模型语句出错');
}

运行实例 »

点击 "运行实例" 按钮查看在线实例


Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!