PHPackages                             ewc/db-multi-connect - 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. ewc/db-multi-connect

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

ewc/db-multi-connect
====================

MySQL PDO Database Multi Connection, Master - Slave Handler System.

04PHP

Since Apr 11Pushed 7y ago1 watchersCompare

[ Source](https://github.com/EvilWizard99/db-multi-connect)[ Packagist](https://packagist.org/packages/ewc/db-multi-connect)[ RSS](/packages/ewc-db-multi-connect/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependenciesVersions (1)Used By (0)

Evil Wizard Creations Multi Connection MySQL Database Handler
=============================================================

[](#evil-wizard-creations-multi-connection-mysql-database-handler)

PDO MySQL Database Multi Connection, Master - Slave Handler System.

Features
--------

[](#features)

- Requires the definition of **APP\_ROOT** for the default config access to be used
- Config file support
- Multi DSN connection aliasing
- Ability to retry the Query for connection timeout with automatic reconnect
- Keep connection alive
- Wrapper to index PDOStatement results by a field value
- PSR-4 autoloading compliant structure
- Comprehensive Guides and tutorial
- Easy to use to any framework or even a plain php file

Configuration
-------------

[](#configuration)

The main section of the config.

- **default\_connection** - *The default connection alias to use if none specified.*
- **connections** - *A collection of database connection alias names and connection specific config.*

The connections sections are grouped with the database connection being aliased as the config key name and requires the following.

- **env** - *The connection environment.*
- **dsn** - *The connection data source name to connect to.*
- **database** - *The database name the connection is for.*
- **username** - *The database username to use for the connection.*
- **password** - *The password to use in conjunction with the username.*
- **port** - *Optional database connection port number, defaults to 3306.*
- **use\_mamp\_sockets** - *Optional flag to indicate the MAMP socket config should be added to the PDO connection.*

#### Example YAML Config Content

[](#example-yaml-config-content)

```
default_connection: main
connections:
    main:
        env: local
        dsn: localhost
        database: database
        username: username
        password: password
        port: 3306
        use_mamp_sockets: false

```

ToDo
----

[](#todo)

- **Manager** - *Support multiple username connections on the same host in addConnectionFromConfig().*
- **Manager** - *Check alias name for \_slave to use replication slaves and separate the configs and connections in makeNewConnection().*
- **Manager** - *Set the default connection as master on instance creation.*
- **Connection** - *Log SQL failure and check if it is a MySQL Server has gone away error and needs to reconnect in query().*
- **Connection** - *Add the DB aliases for the connection and PDO connections attributes in \_\_toString().*
- **Manager** - *Incorporate the use of the env setting.*

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3905481?v=4)[EvilWizard](/maintainers/EvilWizard)[@evilwizard](https://github.com/evilwizard)

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/ewc-db-multi-connect/health.svg)

```
[![Health](https://phpackages.com/badges/ewc-db-multi-connect/health.svg)](https://phpackages.com/packages/ewc-db-multi-connect)
```

###  Alternatives

[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k117.2M117](/packages/jdorn-sql-formatter)[propel/propel1

Propel is an open-source Object-Relational Mapping (ORM) for PHP5.

8351.6M87](/packages/propel-propel1)[jfelder/oracledb

Oracle DB driver for Laravel

11518.4k](/packages/jfelder-oracledb)

PHPackages © 2026

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