-
insert_id:得到自增长的值 affected_rows值为三种: 1.受影响记录条数 2.-1,代表sql语句有问题 3.0,代表没有受影响记录的条数查看全部
-
mysqli 比 pdo 的效率快多了查看全部
-
数据库建表查看全部
-
insert_id:得到自增长的值 affected_rows值为三种: 1.受影响记录条数 2.-1,代表sql语句有问题 3.0,代表没有受影响记录的条数查看全部
-
...查看全部
-
<?php header('content-type:text/html;charset=utf-8'); $mysqli = new mysqli('localhost','root','root','test'); if($mysqli->connect_errno){ die($mysqli->connect_error); } $mysqli->set_charset('utf8'); //关闭自动提交功能 $mysqli->autocommit(FALSE); $sql = "UPDATE account SET money = money-200 WHERE username = 'king'"; $res1 = $mysqli->query($sql); $res1_rows = $msyqli->affected_rows; $sql2 = "UPDATE account SET money = money+200 WHERE username = 'queen'"; $res2 = $mysqli->query($sql2); $res2_rows = $mysqli->affected_rows; if($res1 && $res1_rows>0 && $res2 && $res2_rows>0){ //提交 $msyqli->commit(); echo 'success'; $mysqli->autocommit(TRUE); } else{ //事务回滚 $mysqli->rollback(); echo 'fail'; } $mysqli->close(); ?>查看全部
-
<?php header('content-type:text/html;charset=utf-8'); $mysqli = new mysqli('localhost','root','root','test'); if($mysqli->connect_errno){ die($mysqli->connect_error); } $mysqli->set_charset('utf8'); $sql = "select userid,username,userjob from user where userid >=?"; $mysqli_stmt = $mysqli->prepare($sql); $id = 20; $mysqli_stmt->bind_param('i',$id); if($mysqli_stmt->excute() ){ //bind_result()绑定结果集中的值到变量 $mysqli_stmt->bind_result($id, $name, $job); while($msyqli_stmt->fetch() ){ //通过fetch()遍历结果集 echo 'ID'.$id.'<br/>'; echo '昵称'.$name.'<br/>'; echo '身份'.$job.'<br/>'; echo '<hr/>'; } } $mysqli_stmt->free_result(); $mysqli_stmt->close(); $mysqli->close(); ?>查看全部
-
sql查看全部
-
$mysqli->multi_query($sql); 必须第一条成功,后面两条才能执行查看全部
-
escape_string转义查看全部
-
法规查看全部
-
$mysqli = new musqli('localhost','root','test'); if($mysqli->connect_errno){ die('connect error:'.$mysqli->connect_error); } $mysqli->set_charset ('utf8'); //执行单条查询语句 $sql = "INSERT user(username,password) VALUES('king','king'),('king2','king2'),('king3','king3'),('king4','king4');"; $res = $mtsqli->query($sql); if($res){ echo'恭喜您注册成功,您是网站的第'.$mysqli->insert_id().位用户 echo '有'.$mysqli->affectd_rows.'记录被影响'. //id子增长,提取最新插入的 }else{ echo 'ERROR'.$mysqli->errno.":"$mysqli->error; }查看全部
-
1.建立到mydql数据的链接 $mysqli = @new mysqli('localhost','root','root','test'); 或者$mysqli = new mysqli() $mysqli->connect('127.0.0.1','root','root','text'); 2.打开指定的数据库 $musqli->select_db('test'); //$mysqli->connect_errno 错误编号 //$mysqli->connect_error 错误信息 if($mysqli->connect_errno){ die('connect error:'$mysqli->connect_error); }查看全部
-
extension_loaded("mysqli");查看全部
-
配置php配置文件开启php_mysqli,dll扩展 配置extension_dir = ext目录所在位置 重启服务器 wanp已经默认打开mysqli查看全部
举报
0/150
提交
取消