PHPackages                             dshafik/php7-mysql-shim - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. dshafik/php7-mysql-shim

ActiveLibrary

dshafik/php7-mysql-shim
=======================

A PHP 7 shim for ext/mysql

1.0.0beta4(5y ago)390758.5k—3.3%97[5 PRs](https://github.com/dshafik/php7-mysql-shim/pulls)3MITPHPPHP &gt;=5.3.6

Since Jul 4Pushed 1y ago15 watchersCompare

[ Source](https://github.com/dshafik/php7-mysql-shim)[ Packagist](https://packagist.org/packages/dshafik/php7-mysql-shim)[ RSS](/packages/dshafik-php7-mysql-shim/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (6)Dependencies (3)Versions (17)Used By (3)

[![Build Status](https://github.com/dshafik/php7-mysql-shim/workflows/Unit%20Tests/badge.svg)](https://github.com/dshafik/php7-mysql-shim/actions)[![Code Coverage](https://camo.githubusercontent.com/94528507b8552ebf369789485dc0257386463ea74a7f45fe9cfb39bfc6e0837f/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f75726c3d68747470733a2f2f676973742e67697468756275736572636f6e74656e742e636f6d2f6473686166696b2f65653739353237653030393861666561313437626666633333626637313064332f7261772f636f7665726167652e6a736f6e)](https://camo.githubusercontent.com/94528507b8552ebf369789485dc0257386463ea74a7f45fe9cfb39bfc6e0837f/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f75726c3d68747470733a2f2f676973742e67697468756275736572636f6e74656e742e636f6d2f6473686166696b2f65653739353237653030393861666561313437626666633333626637313064332f7261772f636f7665726167652e6a736f6e)

 [![](https://private-user-images.githubusercontent.com/58074/364584806-28526ddb-1748-46ba-a984-81bcc238274d.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVk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UFtei1EYXRlPTIwMjYwMzI3VDE5NTQ0OFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTI1NWMyYWU5MzVkYmU5ODQ1NWU1Nzk4MzE2NzY2OTBkNTcyNDZmMDMwYzZmMzhjMGMxMDE1NTNkZjVkNjFmNTgmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.1SxsvKsLJBD2Gb4-25_zfOXgWNSutqu3EYjTR0yobZo)

PHP 7 Shim for ext/mysql
========================

[](#php-7-shim-for-extmysql)

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
----------------------------------

[](#why-you-shouldnt-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](http://php.net/manual/en/pdo.prepared-statements.php) to ensure you are securely interacting with your database.**

Installation
------------

[](#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
-----

[](#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
-------

[](#caveats)

- Calls to `is_resource()` and `get_resource_type()` on MySQL connections and results will fail as these are now their `mysqli` equivalents.
- Some errors are now from `ext/mysqli`, and others are `E_USER_WARNING` instead of `E_WARNING`.
- You must use the `mysqli.*` INI entries instead of `mysql.*` (e.g. `mysqli.default_user` instead of `mysql.default_user`)
- If no host, username, password parameter is provided when using the `mysql_*` functions, the default values from the corresponding `mysqli.*` settings from `php.ini` file will be used (e.g. `mysqli.default_host`, `mysqli.default_user`, `mysqli.default_pw`)

Alternatives
------------

[](#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.

###  Health Score

45

—

FairBetter than 93% of packages

Maintenance28

Infrequent updates — may be unmaintained

Popularity59

Moderate usage in the ecosystem

Community34

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 74.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~324 days

Recently: every ~383 days

Total

6

Last Release

1982d ago

Major Versions

0.2.0 → 1.0.0beta12017-01-09

### Community

Maintainers

![](https://www.gravatar.com/avatar/950c044ac0c43c20172483e6cd7c13afed5976380e86dad6308cc4a667329b27?d=identicon)[dshafik](/maintainers/dshafik)

---

Top Contributors

[![dshafik](https://avatars.githubusercontent.com/u/58074?v=4)](https://github.com/dshafik "dshafik (137 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (16 commits)")[![naaando](https://avatars.githubusercontent.com/u/12532760?v=4)](https://github.com/naaando "naaando (5 commits)")[![philip](https://avatars.githubusercontent.com/u/42943?v=4)](https://github.com/philip "philip (5 commits)")[![staabm](https://avatars.githubusercontent.com/u/120441?v=4)](https://github.com/staabm "staabm (4 commits)")[![eryx12o45](https://avatars.githubusercontent.com/u/6588960?v=4)](https://github.com/eryx12o45 "eryx12o45 (2 commits)")[![bpolaszek](https://avatars.githubusercontent.com/u/5569077?v=4)](https://github.com/bpolaszek "bpolaszek (2 commits)")[![ASA1-ET-JENKINS](https://avatars.githubusercontent.com/u/48315530?v=4)](https://github.com/ASA1-ET-JENKINS "ASA1-ET-JENKINS (2 commits)")[![SwenVanZanten](https://avatars.githubusercontent.com/u/3099122?v=4)](https://github.com/SwenVanZanten "SwenVanZanten (1 commits)")[![techhead](https://avatars.githubusercontent.com/u/311112?v=4)](https://github.com/techhead "techhead (1 commits)")[![webysther](https://avatars.githubusercontent.com/u/750007?v=4)](https://github.com/webysther "webysther (1 commits)")[![gharlan](https://avatars.githubusercontent.com/u/330436?v=4)](https://github.com/gharlan "gharlan (1 commits)")[![mekras](https://avatars.githubusercontent.com/u/192067?v=4)](https://github.com/mekras "mekras (1 commits)")[![mgilfillan](https://avatars.githubusercontent.com/u/25685838?v=4)](https://github.com/mgilfillan "mgilfillan (1 commits)")[![mlocati](https://avatars.githubusercontent.com/u/928116?v=4)](https://github.com/mlocati "mlocati (1 commits)")[![muhammedalialat](https://avatars.githubusercontent.com/u/8521941?v=4)](https://github.com/muhammedalialat "muhammedalialat (1 commits)")[![sonnysavage](https://avatars.githubusercontent.com/u/5487663?v=4)](https://github.com/sonnysavage "sonnysavage (1 commits)")[![stefket](https://avatars.githubusercontent.com/u/1169903?v=4)](https://github.com/stefket "stefket (1 commits)")

###  Code Quality

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/dshafik-php7-mysql-shim/health.svg)

```
[![Health](https://phpackages.com/badges/dshafik-php7-mysql-shim/health.svg)](https://phpackages.com/packages/dshafik-php7-mysql-shim)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
