Download the PHP package corn/mypdoms without Composer

On this page you can find all versions of the php package corn/mypdoms. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package mypdoms

MyPDOMS

MyPDOMS is intended to be a drop-in replacement for most common tasks performed with mysqlnd_ms.

Requires PHP 5.6 or above.

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

Table of Contents

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:

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

You don't need to supply any slave configuration. If you don't configure any slaves, then all queries will go to the master.

Establishing a Connection

Slave connections are lazily-established, but a master connection is established when you construct a new MyPDOMS instance. The constructor is identical to the standard PDO constructor but with these caveats:

Here's an example:

Differences from PDO

MyPDOMS is a subclass of PDO so PDO's documentation also applies to MyPDOMS with these core differences:

Query Routing

Queries will be routed to either the master or to a slave depending on this sequence of checks:

  1. Leading comments in the SQL will be checked for SQL Hints
    1. If HINT_MASTER is found then the query will be sent to the master
    2. If HINT_SLAVE is found then the query will be sent to a slave
    3. If HINT_LAST_USED is found then the query will be sent to the last used connection
  2. If the first SQL-word is one of INSERT, UPDATE, DELETE, REPLACE, LOAD, ALTER, CREATE, DROP, RENAME, or TRUNCATE then the query will be sent to the master
  3. If the first SQL-word is SELECT and the query ends in FOR UPDATE then the query will be sent to the master
  4. If none of the above match, then the query will be sent to a slave

Note: The routing logic does not check to see if a transaction is open, because all queries that can result in updates or locks are already automatically routed to the master.

SQL Hints

SQL hints can be used to override the default query routing logic. These SQL hints are available, and should be prepended to queries in a comment:

Example:

If you want to replace mysqlnd_ms and not go back and update all your code, you can use this snippet:

Slave Selection

When a query is due to be routed to a slave, a slave is selected per-query. That is, slaves are not selected per-request but are selected every time a query is executed. Presently, the only supported selection mechanism is unweighted random, in which every query will be sent to a random slave, with all slaves having an equal probability of being chosen.

Example:

Different selection algorithms are expected to be added in later releases, but if you wish to define your own selection algorithm, you may extend MyPDOMS and override the getSlave method.

Prepared Statements

Both emulated and non-emulated prepared statements are fully supported, as they are assigned a connection at prepare-time. That is, after a PDOStatement is returned from prepare(), the statement will always use the same database each time it is executed.

Note: lastUsedHost is updated when a statement is prepared, but not when it is executed. This means that the following is possible:


All versions of mypdoms with dependencies

PHP Build Version
Package Version
Requires ext-pdo Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package corn/mypdoms contains the following files

Loading the files please wait ....