3 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
9 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
13 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
15 * This software consists of voluntary contributions made by many individuals
16 * and is licensed under the MIT license. For more information, see
17 * <http://www.doctrine-project.org>.
20 namespace Doctrine\DBAL\Sharding;
22 use Doctrine\DBAL\Connection;
25 * Sharding Manager gives access to APIs to implementing sharding on top of
26 * Doctrine\DBAL\Connection instances.
28 * For simplicity and developer ease-of-use (and understanding) the sharding
29 * API only covers single shard queries, no fan-out support. It is primarily
30 * suited for multi-tenant applications.
32 * The assumption about sharding here
33 * is that a distribution value can be found that gives access to all the
34 * necessary data for all use-cases. Switching between shards should be done with
35 * caution, especially if lazy loading is implemented. Any query is always
36 * executed against the last shard that was selected. If a query is created for
37 * a shard Y but then a shard X is selected when its actually excecuted you
38 * will hit the wrong shard.
40 * @author Benjamin Eberlei <kontakt@beberlei.de>
42 interface ShardManager
45 * Select global database with global data.
47 * This is the default database that is connected when no shard is
52 function selectGlobal();
55 * SELECT queries after this statement will be issued against the selected
58 * @throws ShardingException If no value is passed as shard identifier.
59 * @param mixed $distributionValue
60 * @param array $options
63 function selectShard($distributionValue);
66 * Get the distribution value currently used for sharding.
70 function getCurrentDistributionValue();
73 * Get information about the amount of shards and other details.
75 * Format is implementation specific, each shard is one element and has a
76 * 'name' attribute at least.
83 * Query all shards in undefined order and return the results appended to
84 * each other. Restore the previous distribution value after execution.
86 * Using {@link Connection::fetchAll} to retrieve rows internally.
89 * @param array $params
93 function queryAll($sql, array $params, array $types);