PHP7 中 MySql连接使用
2022-07-28 15:20:24
125
{{single.collect_count}}

php7中mysql的连接与使用与PHP5中大不相同

PHP5中mysql_connect()等函数大多被PHP7中类的成员函数所代替。PHP5中连接mysql是过程性的,而PHP7中强调了类的使用与面向对象的方法

$user = new mysqli();//Connect to mysql$user->connect("localhost", "root", "q721@Ms67", "Student");

mysql的连接被mysqli类所替代

//Search in mysql$query = 'SELECT * FROM users';//Use a variable to save result$result = $user->query($query);

查询语句也变成了类的成员函数

回帖
全部回帖({{commentCount}})
{{item.user.nickname}} {{item.user.group_title}} {{item.friend_time}}
{{item.content}}
{{item.comment_content_show ? '取消' : '回复'}} 删除
回帖
{{reply.user.nickname}} {{reply.user.group_title}} {{reply.friend_time}}
{{reply.content}}
{{reply.comment_content_show ? '取消' : '回复'}} 删除
回帖
收起
没有更多啦~
{{commentLoading ? '加载中...' : '查看更多评论'}}