dshafik/php7-mysql-shim
Composer 安装命令:
composer require dshafik/php7-mysql-shim
包简介
A PHP 7 shim for ext/mysql
README 文档
README
PHP 7 Shim for ext/mysql
This library attempts to create a drop-in replacement for ext/mysql on PHP 7 using mysqli.
For the most part, it should just work.
Why You Shouldn't Use This Library
This library is meant to be a stop-gap. It will be slower than using the native functions directly.
You should switch to ext/pdo_mysql or ext/mysqli, and migrate to prepared queries to ensure you are securely interacting with your database.
Installation
To install, either add dshafik/php7-mysql-shim to your composer.json:
$ composer require dshafik/php7-mysql-shim
or, clone/download this repo, and include lib/mysql.php in your project.
Usage
When installed with composer, the library is included automatically.
Once the lib/mysql.php file is included, it will create mysql_* functions if they don't already exist. You may safely include the file in a PHP 5.3.6+ project, it will do nothing if the mysql extension is already available.
Caveats
- Calls to
is_resource()andget_resource_type()on MySQL connections and results will fail as these are now theirmysqliequivalents. - Some errors are now from
ext/mysqli, and others areE_USER_WARNINGinstead ofE_WARNING. - You must use the
mysqli.*INI entries instead ofmysql.*(e.g.mysqli.default_userinstead ofmysql.default_user) - If no host, username, password parameter is provided when using the
mysql_*functions, the default values from the correspondingmysqli.*settings fromphp.inifile will be used (e.g.mysqli.default_host,mysqli.default_user,mysqli.default_pw)
Alternatives
Instead of using this drop-in-replacement library you should consider refactoring your code from mysql to e.g. mysqli. This process can be automated with e.g. https://stackoverflow.com/a/61597957
dshafik/php7-mysql-shim 适用场景与选型建议
dshafik/php7-mysql-shim 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 783.28k 次下载、GitHub Stars 达 389, 最近一次更新时间为 2015 年 12 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 dshafik/php7-mysql-shim 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 dshafik/php7-mysql-shim 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 783.28k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 389
- 点击次数: 35
- 依赖项目数: 4
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-12-04