PHPackages                             sshilko/php-sql-mydb - 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. [Database &amp; ORM](/categories/database)
4. /
5. sshilko/php-sql-mydb

ActiveLibrary[Database &amp; ORM](/categories/database)

sshilko/php-sql-mydb
====================

Simple yet powerful PHP wrapper for MySQL

2.0.0(2y ago)24MITPHPPHP ^8.0 || ^8.1 || ^8.2CI passing

Since Dec 4Pushed 1mo agoCompare

[ Source](https://github.com/sshilko/php-sql-mydb)[ Packagist](https://packagist.org/packages/sshilko/php-sql-mydb)[ Fund](https://paypal.me/sergeishilko)[ GitHub Sponsors](https://github.com/sshilko)[ RSS](/packages/sshilko-php-sql-mydb/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (12)Versions (3)Used By (0)

MyDb - Component
================

[](#mydb---component)

 [![Project status - active](https://camo.githubusercontent.com/b411594136144442e4c5e6e2e2d63ee7461762fbe5e2eb0e5abbbec3fd812845/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7374617475732d6163746976652d73756363657373)](https://camo.githubusercontent.com/b411594136144442e4c5e6e2e2d63ee7461762fbe5e2eb0e5abbbec3fd812845/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7374617475732d6163746976652d73756363657373) [![Latest Stable Version](https://camo.githubusercontent.com/0d726ead1a1c6062692f48bedb1e979d1f476975257cbdfc7d67bf6dd3c00cfd/68747470733a2f2f706f7365722e707567782e6f72672f737368696c6b6f2f7068702d73716c2d6d7964622f762f737461626c65)](https://packagist.org/packages/sshilko/php-sql-mydb) [![Total Downloads](https://camo.githubusercontent.com/6455f330aedbc2e144ab2e2c95cdf44ad31b69a23cf85a383134b69c269464e0/68747470733a2f2f706f7365722e707567782e6f72672f737368696c6b6f2f7068702d73716c2d6d7964622f646f776e6c6f616473)](https://packagist.org/packages/sshilko/php-sql-mydb/stats) [![PHP Required Version](https://camo.githubusercontent.com/1c9535c05cfaf9f30ad44a9dea1de1698926e2594fc03b82f5d47782e76bdb2b/68747470733a2f2f706f7365722e707567782e6f72672f737368696c6b6f2f7068702d73716c2d6d7964622f726571756972652f706870)](https://packagist.org/packages/sshilko/php-sql-mydb) [![MIT License](https://camo.githubusercontent.com/eecfbd4ece2fbb288270c3f35d18890e0aecde72e411210abce73c58ec4abb48/68747470733a2f2f706f7365722e707567782e6f72672f737368696c6b6f2f7068702d73716c2d6d7964622f6c6963656e7365)](https://choosealicense.com/licenses/mit/) [ ![Psalm Coverage](https://camo.githubusercontent.com/28aaea5e85ffd27a3c338b2666c6e305b7ef4f5ce024ea3ce6f5beb8eecf3a2c/68747470733a2f2f73686570686572642e6465762f6769746875622f737368696c6b6f2f7068702d73716c2d6d7964622f636f7665726167652e737667)](https://psalm.dev/docs/running_psalm/command_line_usage/#shepherd) [![](https://camo.githubusercontent.com/edb82dcfb39529a481c403729fb3e478cc5db3fd88076831a4a039e64559e8ef/68747470733a2f2f686974732e736565796f756661726d2e636f6d2f6170692f636f756e742f696e63722f62616467652e7376673f75726c3d68747470732533412532462532466769746875622e636f6d253246737368696c6b6f2532467068702d73716c2d6d79646226636f756e745f62673d253233373943383344267469746c655f62673d2532333535353535352669636f6e3d2669636f6e5f636f6c6f723d253233453745374537267469746c653d6869747326656467655f666c61743d66616c7365)](https://camo.githubusercontent.com/edb82dcfb39529a481c403729fb3e478cc5db3fd88076831a4a039e64559e8ef/68747470733a2f2f686974732e736565796f756661726d2e636f6d2f6170692f636f756e742f696e63722f62616467652e7376673f75726c3d68747470732533412532462532466769746875622e636f6d253246737368696c6b6f2532467068702d73716c2d6d79646226636f756e745f62673d253233373943383344267469746c655f62673d2532333535353535352669636f6e3d2669636f6e5f636f6c6f723d253233453745374537267469746c653d6869747326656467655f666c61743d66616c7365) [![Code size](https://camo.githubusercontent.com/dc209ba3c25eee8168e272fdbe3b17f301ff097bbac75c61cf25b964f91fa57c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c616e6775616765732f636f64652d73697a652f737368696c6b6f2f7068702d73716c2d6d796462)](https://camo.githubusercontent.com/dc209ba3c25eee8168e272fdbe3b17f301ff097bbac75c61cf25b964f91fa57c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c616e6775616765732f636f64652d73697a652f737368696c6b6f2f7068702d73716c2d6d796462)
 [![PHPUnit coverage](https://raw.githubusercontent.com/sshilko/php-sql-mydb/pages/php/phpunit/phpunit-coverage-badge.svg)](https://raw.githubusercontent.com/sshilko/php-sql-mydb/pages/php/phpunit/phpunit-coverage-badge.svg) [![PHPUnit classes coverage](https://raw.githubusercontent.com/sshilko/php-sql-mydb/pages/php/phpunit/phpunit-coverage-badge-classes.svg)](https://raw.githubusercontent.com/sshilko/php-sql-mydb/pages/php/phpunit/phpunit-coverage-badge-classes.svg) [![PHPUnit lines coverage](https://raw.githubusercontent.com/sshilko/php-sql-mydb/pages/php/phpunit/phpunit-coverage-badge-lines.svg)](https://raw.githubusercontent.com/sshilko/php-sql-mydb/pages/php/phpunit/phpunit-coverage-badge-lines.svg) [![PHPUnit methods coverage](https://raw.githubusercontent.com/sshilko/php-sql-mydb/pages/php/phpunit/phpunit-coverage-badge-methods.svg)](https://raw.githubusercontent.com/sshilko/php-sql-mydb/pages/php/phpunit/phpunit-coverage-badge-methods.svg)
 [![8.1 Phan build](https://github.com/sshilko/php-sql-mydb/actions/workflows/phpphan.yml/badge.svg)](https://sshilko.com/php-sql-mydb/php/phan/) [![8.1 Psalm build](https://github.com/sshilko/php-sql-mydb/actions/workflows/phppsalm.yml/badge.svg)](https://sshilko.com/php-sql-mydb/php/psalm/) [![8.1 PHPMd build](https://github.com/sshilko/php-sql-mydb/actions/workflows/phpmd.yml/badge.svg)](https://sshilko.com/php-sql-mydb/php/phpmd/) [![8.1 PHPStan build](https://github.com/sshilko/php-sql-mydb/actions/workflows/phpstan.yml/badge.svg)](https://sshilko.com/php-sql-mydb/php/phpstan/) [![8.1 PHPCodeSniffer build](https://github.com/sshilko/php-sql-mydb/actions/workflows/phpcs.yml/badge.svg)](https://sshilko.com/php-sql-mydb/php/phpcs/) [![8.1 PHPDocumentor build](https://github.com/sshilko/php-sql-mydb/actions/workflows/phpdoc.yml/badge.svg)](https://sshilko.com/php-sql-mydb/php/phpdoc/) [![8.1 Pdepend build](https://github.com/sshilko/php-sql-mydb/actions/workflows/phppdepend.yml/badge.svg)](https://sshilko.com/php-sql-mydb/php/pdepend/) [![8.1 PHPUnit build](https://github.com/sshilko/php-sql-mydb/actions/workflows/phpunit.yml/badge.svg)](https://sshilko.com/php-sql-mydb/php/phpunit/html/) [![8.0 PHPUnit build](https://github.com/sshilko/php-sql-mydb/actions/workflows/phpunit80.yml/badge.svg)](https://github.com/sshilko/php-sql-mydb/actions/workflows/phpunit80.yml) [![8.1 PHPUnit build](https://github.com/sshilko/php-sql-mydb/actions/workflows/phpunit81.yml/badge.svg)](https://github.com/sshilko/php-sql-mydb/actions/workflows/phpunit81.yml) [![8.2 PHPUnit build](https://github.com/sshilko/php-sql-mydb/actions/workflows/phpunit82.yml/badge.svg)](https://github.com/sshilko/php-sql-mydb/actions/workflows/phpunit82.yml) [![GithubPages build](https://github.com/sshilko/php-sql-mydb/actions/workflows/github-pages.yml/badge.svg)](https://github.com/sshilko/php-sql-mydb/actions/workflows/github-pages.yml)

Simple PHP client for MySQL database

#### Installation

[](#installation)

```
composer require sshilko/php-sql-mydb

```

#### [Compatibility](https://sshilko.com/php-sql-mydb/php/)

[](#compatibility)

- PHP 8.0, 8.1, 8.2
- MySQL &gt;=5.7.8, 8.0
- MariaDB not compatible (TODO)

#### How this client helps you talk SQL to MySQL server

[](#how-this-client-helps-you-talk-sql-to-mysql-server)

- Make MySQL behave like a “traditional” SQL database system
    - `TRADITIONAL` mode, a simple description of this mode is [“give an error instead of a warning”](https://dev.mysql.com/doc/refman/5.7/en/sql-mode.html#sqlmode_traditional)
- Friendly transactions
    - `autocommit = 0`
    - explicit `commit` [on gracefull shutdown](https://dev.mysql.com/doc/refman/5.7/en/innodb-autocommit-commit-rollback.html)
- Explicit timeouts
    - 05 seconds `client-side` connect-timeout
    - 89 seconds `server-side` SELECT query timeout
    - 90 seconds `client-side` read-timeout for any query
    - 7200 seconds non-interactive connection `idle timeout`
    - `mysqlnd.net_read_timeout`
    - respect client disconnect in php-fpm `function.ignore-user-abort.php`
- Performance boost
    - increased `MYSQLI_OPT_NET_READ_BUFFER_SIZE`
    - increased `MYSQLI_OPT_NET_CMD_BUFFER_SIZE`
    - read-only InnoDB [optimizations](https://dev.mysql.com/doc/refman/5.6/en/innodb-performance-ro-txn.html)
    - READ COMMITED session transaction isolation level for readonly connections
    - async command execution
    - move mysql resultset to PHP userspace memory `MYSQLI_STORE_RESULT_COPY_DATA`
    - use of `fetch_all` from [PHP Mysql native driver](https://www.php.net/manual/en/intro.mysqlnd.php)
- UTF-8
    - `utf8mb4` character set
    - `UTC` timezone
- Quality error handling
    - PHP default error-reporting `E_ALL & ~E_WARNING & ~E_NOTICE`
    - MySQL default error-reporting `MYSQLI_REPORT_ALL ^ MYSQLI_REPORT_STRICT ^ MYSQLI_REPORT_INDEX`
    - `SIGTERM, SIGINT, SIGHUP` signals trap
    - connection retry
- PHPUnit &amp; Static code analysis
    - unit-tested, static analysed codebase

#### What is the best use-case for this library

[](#what-is-the-best-use-case-for-this-library)

- High performance, low-latency data-intensive applications
- No prepared statements requirement
- No 3rd party dependencies
- No run-time/compile-time steps
- Easy to start with and/or [integrate](https://refactoring.guru/design-patterns/php) into existing codebase

#### Out of scope

[](#out-of-scope)

This library is **not** intending to become a framework, to *keep focus* and minimize codebase, it does not provide

- Input [validation](https://symfony.com/doc/current/validation.html), [API](https://refactoring.guru/design-patterns/facade) facade
- [Object-relational mapping](https://en.wikipedia.org/wiki/Object%E2%80%93relational_mapping), ORM
- [Active record](https://en.wikipedia.org/wiki/Active_record_pattern) pattern
- [Repository](https://symfony.com/doc/current/doctrine.html#querying-for-objects-the-repository) pattern
- Import and export of data

please re-use existing solutions that best fit your requirements.

#### Why this library exists

[](#why-this-library-exists)

- MySQL database is fast, reliable and scalable, php runtime is the same
- Value developers time and do not add complexity where possible
- Measure app's performance with real-world datasets and organic load
- Optimize for my use-case, focus on bottlenecks, remember that there is no NoSQL silver bullet
- Do not optimize early - resources like CPU, memory are cheap
- Focus on building architecture, learn from others and improve over time

#### Future roadmap

[](#future-roadmap)

- MariaDB compatibility layer (variables and init command syntax is different between mysql and mariadb)
- MydbFactory responsible for initializing defaults

#### Contributing

[](#contributing)

- Please read [contributing](CONTRIBUTING) document

#### Authors

[](#authors)

Sergei Shilko

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance60

Regular maintenance activity

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~394 days

Total

2

Last Release

867d ago

Major Versions

1.0.0 → 2.0.02024-01-03

PHP version history (2 changes)1.0.0PHP ^7.4 || ^8.0 || ^8.1 || ^8.2

2.0.0PHP ^8.0 || ^8.1 || ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/74fb0579a62a4158388bcf5a61a76922c7a3e7776217ea5fc33a87790011b17e?d=identicon)[sshilko](/maintainers/sshilko)

---

Top Contributors

[![sshilko](https://avatars.githubusercontent.com/u/1147808?v=4)](https://github.com/sshilko "sshilko (246 commits)")

---

Tags

mysqlphpphpdatabasemysqlpdomysqlimysqlnd

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/sshilko-php-sql-mydb/health.svg)

```
[![Health](https://phpackages.com/badges/sshilko-php-sql-mydb/health.svg)](https://phpackages.com/packages/sshilko-php-sql-mydb)
```

###  Alternatives

[doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.

9.7k578.4M5.6k](/packages/doctrine-dbal)[sergeytsalkov/meekrodb

The Simple PHP/MySQL Library

341387.0k10](/packages/sergeytsalkov-meekrodb)[clouddueling/mysqldump-php

PHP version of mysqldump cli that comes with MySQL

1.3k22.9k](/packages/clouddueling-mysqldump-php)[stefangabos/zebra_database

An advanced, compact and lightweight MySQL database wrapper library, built around PHP's MySQLi extension.

11812.0k](/packages/stefangabos-zebra-database)[popphp/pop-db

Pop Db Component for Pop PHP Framework

1814.6k11](/packages/popphp-pop-db)[riverside/php-orm

PHP ORM micro-library and query builder

111.2k](/packages/riverside-php-orm)

PHPackages © 2026

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