MySQL原生PHP操作-天龙八步
2024-09-01 17:57:47
<?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); ?>
最新文章
- mac终端命令
- Java提高篇——理解String 及 String.intern() 在实际中的应用
- Dell DRAC的重启方法
- (转) PowerDesigner逆向工程导入MYSQL数据库总结
- pycharm实用快捷键
- oracle sql获取随机数
- Eclipse : cannot open output file(c++)
- 一个简洁通用的调用DLL函数的帮助类
- [Regex Expression] Use Shorthand to Find Common Sets of Characters
- (Pre sell) ZOPO ZP998 (C2 II) 5.5 inch smart phone True Octa Core MTK6592 1920X1080 FHD screen 401 ppi 2GB/32GB 14.0Mp camera-in Mobile Phones from Electronics on Aliexpress.com
- 关于对WEB标准以及W3C的理解与认识问题
- Oozie安装时放置Mysql驱动包的总结(网上最全)
- 读了前半本<;Thinking in Java>;
- Windows DLL资料整理
- java Servlet文件拷贝的模板代码
- bzoj5100 [POI2018]Plan metra 构造
- 洛谷P2604 网络扩容 拆点+费用流
- 使用Eclipse绑定Tomcat并发布应用
- Docker:镜像构建与进入容器总结
- activeX