php7移除的一些函数
今天使用php7版本开发,使用mysql_connect连接数据库时
提示:Fatal error: Uncaught Error: Call to undefined function mysql_connect()
查了下手册发现是php7已经彻底移除了mysql扩展,同时删除的扩展和sapi还有:
sapi/aolserver
sapi/apache
sapi/apache_hooks
sapi/apache2filter
sapi/caudium
sapi/continuity
sapi/isapi
sapi/milter
sapi/nsapi
sapi/phttpd
sapi/pi3web
sapi/roxen
sapi/thttpd
sapi/tux
sapi/webjames
ext/mssql
ext/sybase_ct
ext/ereg
如果项目从php5.x升级到php7,得检查下是否使用到了上面的扩展
php连接mysql可以使用mysqli和pdo,推荐使用pdo方式
<?php $pdo = new PDO("mysql:host=localhost;dbname=big;port=3306","root","123456"); $pdo->exec("set names utf8"); $stmt = $pdo->prepare("select * from ih_goods where goods_id =:id"); $stmt->bindValue(":id",1,PDO::PARAM_INT); $stmt->execute(); $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); print_r($rows);exit;
声明:该文观点仅代表作者本人,入门客AI创业平台信息发布平台仅提供信息存储空间服务,如有疑问请联系rumenke@qq.com。
- 上一篇: php大文件切割和合并
- 下一篇: thinkphp5.0极速搭建restful风格接口层实例