首页 > 数据库技术 > 详细

mysqli_stmt预处理类

时间:2014-09-14 12:39:57      阅读:300      评论:0      收藏:0      [点我收藏+]

<?php  $mysqli=new mysqli("localhost", "root", "123456", "xsphpdb");

 $stmt=$mysqli->prepare("select id, name, price, num, desn from shops where id>?");

 $stmt->bind_param("i", $id);

 $stmt->bind_result($id, $name, $price, $num, $desn);

 $id=99;

 $stmt->execute();    $stmt->store_result(); //一次性将结果都取过来 重要

 //字段信息  $result=$stmt->result_metadata();    while($field=$result->fetch_field()){   echo $field->name."--";  }  echo ‘<br>‘;  //记录信息   //$stmt->data_seek(2);  while($stmt->fetch()){   echo "$id--$name---$price---$num---$desn <br>";  }

 echo "记录总数:".$stmt->num_rows;

 $stmt->free_result();

 $stmt->close();

bubuko.com,布布扣

mysqli_stmt预处理类

原文:http://www.cnblogs.com/toward-the-sun/p/3970829.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!