PHPackages                             corn/mypdoms - 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. corn/mypdoms

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

corn/mypdoms
============

Pure-PHP clone-implementation of mysqlnd\_ms built on top of PDO

v1.1.1(7y ago)29.1k↓28.6%3MITPHP

Since Feb 13Pushed 7y ago1 watchersCompare

[ Source](https://github.com/DoctorMcKay/php-mypdoms)[ Packagist](https://packagist.org/packages/corn/mypdoms)[ RSS](/packages/corn-mypdoms/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (6)DependenciesVersions (7)Used By (0)

MyPDOMS
=======

[](#mypdoms)

MyPDOMS is intended to be a drop-in replacement for most common tasks performed with [mysqlnd\_ms](http://php.net/manual/en/book.mysqlnd-ms.php).

Requires PHP 5.6 or above.

**While this is based on PDO, it only supports MySQL.**

Table of Contents
-----------------

[](#table-of-contents)

- [Configuring](#configuring)
- [Establishing a Connection](#establishing-a-connection)
- [Differences from PDO](#differences-from-pdo)
- [Query Routing](#query-routing)
- [SQL Hints](#sql-hints)
- [Slave Selection](#slave-selection)
- [Prepared Statements](#prepared-statements)

Configuring
===========

[](#configuring)

Before you instantiate an instance of `MyPDOMS`, you need to configure it. Configuration is accomplished using the static `setConfig` method, which expects a single parameter of type array. The structure of the expected associative array is:

- `[config name]` - The name of a configuration. Configurations are collections of servers.
    - `master` - Database configuration for your master server
        - `host` - The host where this database is running (required)
        - `port` - The port on which this database is running (optional; defaults to 3306)
        - `username` - Database username (optional; defers to constructor argument if missing)
        - `password` - Database password (optional; defers to constructor argument if missing)
    - `slaves` - Contains your slave server database configurations
        - `[slave name]` - Database configuration for a slave server (can be anything except `master`)
            - `host` - The host where this database is running (required)
            - `port` - The port on which this database is running (optional; defaults to 3306)
            - `username` - Database username (optional; defers to constructor argument if missing)
            - `password` - Database password (optional; defers to constructor argument if missing)

So, for example, you might want to do this:

```
