标签:
预处理查询函数
<?php$host = ‘localhost‘;$user = ‘root‘;$pass = ‘‘;$dbname = ‘db‘;$charset = ‘utf8‘;$m = new mysqli($host,$user,$pass,$dbname);$m->set_charset($charset);//$tn为表名,$w为条件function get_count($tn,$w=‘1=1‘){global $m;$stmt=$m->prepare("select count(*) from $tn where $w");$stmt->execute();$stmt->bind_result($c);$stmt->fetch();$stmt->free_result();$stmt->close();return $c;}
$re=get_count(‘stu‘,‘sscore=90‘);echo $re;

标签:
原文地址:http://www.cnblogs.com/lsr111/p/4553520.html