MySQL原生PHP操作-天龙八步

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

MySQL原生PHP操作-天龙八步

bug毁灭者   2019-11-17 我要评论
<?php
//1、第一步【建立连接】 $conn = mysqli_connect('localhost','root','123456') or die('数据库连接失败!'); //2、第二步【选择数据库】 mysqli_select_db($conn,'new_kt'); //3、第三步【设置字符集】 mysqli_set_charset($conn,'utf8'); //4、第四步【准备sql语句】 $sql = 'select * from `user` limit 10'; //5、第五步【执行sql语句】 $result = mysqli_query($conn,$sql); $new_result = [];//数组结果集 //while($row = mysqli_fetch_array($result)){ //$new_result[]=$row; //} //6、第六步【获取结果集】 //或者如下方式 $new_result = mysqli_fetch_all($result,MYSQLI_ASSOC); $nums = mysqli_num_rows($result);//数据条数 //7、第七步【释放临时数据】 mysqli_free_result($result); //8、第八步【关闭连接】 mysqli_close($conn); ?>

 

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们