Rajout de doctrine/orm
[zf2.biz/galerie.git] / vendor / doctrine / dbal / lib / Doctrine / DBAL / Sharding / ShardManager.php
1 <?php
2 /*
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.
14  *
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>.
18  */
19
20 namespace Doctrine\DBAL\Sharding;
21
22 use Doctrine\DBAL\Connection;
23
24 /**
25  * Sharding Manager gives access to APIs to implementing sharding on top of
26  * Doctrine\DBAL\Connection instances.
27  *
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.
31  *
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.
39  *
40  * @author Benjamin Eberlei <kontakt@beberlei.de>
41  */
42 interface ShardManager
43 {
44     /**
45      * Select global database with global data.
46      *
47      * This is the default database that is connected when no shard is
48      * selected.
49      *
50      * @return void
51      */
52     function selectGlobal();
53
54     /**
55      * SELECT queries after this statement will be issued against the selected
56      * shard.
57      *
58      * @throws ShardingException If no value is passed as shard identifier.
59      * @param mixed $distributionValue
60      * @param array $options
61      * @return void
62      */
63     function selectShard($distributionValue);
64
65     /**
66      * Get the distribution value currently used for sharding.
67      *
68      * @return string
69      */
70     function getCurrentDistributionValue();
71
72     /**
73      * Get information about the amount of shards and other details.
74      *
75      * Format is implementation specific, each shard is one element and has a
76      * 'name' attribute at least.
77      *
78      * @return array
79      */
80     function getShards();
81
82     /**
83      * Query all shards in undefined order and return the results appended to
84      * each other. Restore the previous distribution value after execution.
85      *
86      * Using {@link Connection::fetchAll} to retrieve rows internally.
87      *
88      * @param string $sql
89      * @param array $params
90      * @param array $types
91      * @return array
92      */
93     function queryAll($sql, array $params, array $types);
94 }
95