最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
PHP mysqli扩展库与mysql用法对比
时间:2022-11-14 23:37:32 编辑:袖梨 来源:一聚教程网
1、在PHP中 使用mysqli扩展库对mysql 的dql操作
| 代码如下 | 复制代码 |
|
header("Content-type: text/html;charset=utf-8"); //1、创建MySQLi对象 $mysqli =new MySQLi("localhost","root","root","test"); //2、操作数据库(发送sql) //3、处理结果 var_dump($row); /* foreach($row as $val){ |
|
下面是面向过程的
| 代码如下 | 复制代码 |
|
header("Content-type: text/html;charset=utf-8"); $sql="select *from user1"; $res=mysqli_query($mysqli,$sql); while($row=mysqli_fetch_row($res)){ //释放内存 |
|
2、在PHP中 使用mysqli扩展库对mysql 的dml操作
| 代码如下 | 复制代码 |
|
if($mysqli->connect_error){ //增加一条记录 $res=$mysqli->query($sql); //关闭资源 |
|
3、进行封装
| 代码如下 | 复制代码 |
|
class SqlHelper{ public function __construct(){ //dql operate $res =$this->mysqli->query($sql) or die($this->mysqli->error); //dml operate $res =$this->mysqli->query($sql) or die($this->mysqli->error); |
|
相关文章
- 漫蛙漫画最新版本下载安装-漫蛙漫画官方免费下载及使用教程 12-30
- ARC Raiders延时手雷作用方式和效果大全 12-30
- foxmail网页版登录入口-foxmail官网登录详细教程 12-30
- 浪漫餐厅怎么刷体力 高效刷取方法与囤货技巧攻略 12-30
- photoshop网页版直达入口-photoshop官网极速下载入口 12-30
- 浪漫餐厅电脑怎么玩 模拟器与小程序多渠道畅玩教程 12-30