mysql和mysqli的区别分析

php中文网
发布: 2016-07-25 08:56:23
原创
1304人浏览过
本文介绍下,php中mysql与mysqli在用法上的一些区别,有需要的朋友参考下。

mysql与mysqli的区别: Mysql and Mysqli(Mysql Improved) are two library functions ( or Extension) in the PHP which is used to acces mysql database.Mysqli is the improved version of mysql which support OOPS. The mysqli extension allows you to access the functionality provided by MySQL 4.1 and above.

mysql是非持继连接函数而mysqli是永远连接函数。 mysql每次链接都会打开一个连接的进程而mysqli多次运行mysqli将使用同一连接进程,从而减少了服务器的开销。 如果使用new mysqli('localhost', usenamer', 'password', 'databasename');总是报错,Fatal error: Class 'mysqli' not found in ...那么要检查一下mysqli是不是开启的。 mysqli类不是默认开启的,win下要改php.ini,去掉php_mysqli.dll前的;,linux下要把mysqli编译进去。

In relation to PHP programming language, MySQL is the old database driver, and MySQLi is the Improved driver. MySQLi takes advantage of the newer features of MySQL 5. Lifted verbatim from the php.net site: - Object-oriented interface - Support for Prepared Statements - Support for Multiple Statements - Support for Transactions - Enhanced debugging capabilities - Embedded server support

you have the choice of using mysql, mysqli, or pdo essentially.

If you're simply looking for a relational database, you need look no further than MySQL, though there are many options available. You can use DBD, Postgres, MySQL, MSSQL, sqlite, etc etc etc...

HTH Source(s): http://www.php.net/manual/en/mysqli.over…

mysqli的用法: $mysqli = new mysqli('localhost', 'my_user', 'my_password', 'my_db'); mysql的用法: $link = mysql_connect('example.com:3307', 'mysql_user', 'mysql_password'); 在处理中文乱码问题时,在$link = mysql_connect('example.com:3307', 'mysql_user', 'mysql_password');之后设置连接字符集: mysql_query("set names utf8"); 注意:不能写成utf-8。

设置所操作的数据库: mysql_select_db("my_db"); 而使用mysqli时,数据库名是作为mysqli构造方法的一个参数,所以这时设置连接字符集不起作用。



最佳 Windows 性能的顶级免费优化软件
最佳 Windows 性能的顶级免费优化软件

每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号