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
|
|
|
|
16
|
|
|
use Alcaeus\MongoDbAdapter\Helper; |
17
|
|
|
|
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* The connection point between MongoDB and PHP. |
21
|
|
|
* This class is used to initiate a connection and for database server commands. |
22
|
|
|
* @link http://www.php.net/manual/en/class.mongo.php |
23
|
|
|
* @deprecated This class has been DEPRECATED as of version 1.3.0. |
24
|
|
|
* Relying on this feature is highly discouraged. Please use MongoClient instead. |
25
|
|
|
* @see MongoClient |
26
|
|
|
*/ |
27
|
|
|
class Mongo extends MongoClient { |
|
|
|
|
28
|
|
|
use Helper\Slave; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @deprecated This feature has been DEPRECATED as of version 1.2.3. Relying on this feature is highly discouraged. Please use MongoPool::getSize() instead. |
32
|
|
|
* (PECL mongo >= 1.2.0)<br/> |
33
|
|
|
* Get pool size for connection pools |
34
|
|
|
* @link http://php.net/manual/en/mongo.getpoolsize.php |
35
|
|
|
* @return int Returns the current pool size. |
36
|
|
|
*/ |
37
|
|
|
public function getPoolSize() {} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Connects to paired database server |
41
|
|
|
* @deprecated Pass a string of the form "mongodb://server1,server2" to the constructor instead of using this method. |
42
|
|
|
* @link http://www.php.net/manual/en/mongo.pairconnect.php |
43
|
|
|
* @throws MongoConnectionException |
44
|
|
|
* @return boolean |
45
|
|
|
*/ |
46
|
|
|
public function pairConnect() {} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* (PECL mongo >= 1.2.0)<br/> |
50
|
|
|
* @deprecated This feature has been DEPRECATED as of version 1.2.3. Relying on this feature is highly discouraged. Please use MongoPool::info() instead. |
51
|
|
|
* Returns information about all connection pools. |
52
|
|
|
* @link http://php.net/manual/en/mongo.pooldebug.php |
53
|
|
|
* @return array Each connection pool has an identifier, which starts with the host. For each pool, this function shows the following fields: |
54
|
|
|
* <p><b>in use</b></p> |
55
|
|
|
* <p>The number of connections currently being used by MongoClient instances. |
56
|
|
|
* in pool |
57
|
|
|
* The number of connections currently in the pool (not being used).</p> |
58
|
|
|
* <p><b>remaining</b></p> |
59
|
|
|
* |
60
|
|
|
* <p>The number of connections that could be created by this pool. For example, suppose a pool had 5 connections remaining and 3 connections in the pool. We could create 8 new instances of MongoClient before we exhausted this pool (assuming no instances of MongoClient went out of scope, returning their connections to the pool). |
61
|
|
|
* |
62
|
|
|
* A negative number means that this pool will spawn unlimited connections. |
63
|
|
|
* |
64
|
|
|
* Before a pool is created, you can change the max number of connections by calling Mongo::setPoolSize(). Once a pool is showing up in the output of this function, its size cannot be changed.</p> |
65
|
|
|
* <p><b>timeout</b></p> |
66
|
|
|
* |
67
|
|
|
* <p>The socket timeout for connections in this pool. This is how long connections in this pool will attempt to connect to a server before giving up.</p> |
68
|
|
|
* |
69
|
|
|
*/ |
70
|
|
|
public function poolDebug() {} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* (PECL mongo >= 1.1.0)<br/> |
74
|
|
|
* Change slaveOkay setting for this connection |
75
|
|
|
* @link http://php.net/manual/en/mongo.setslaveokay.php |
76
|
|
|
* @param bool $ok [optional] <p class="para"> |
77
|
|
|
* If reads should be sent to secondary members of a replica set for all |
78
|
|
|
* possible queries using this {@see MongoClient} instance. |
79
|
|
|
* </p> |
80
|
|
|
* @return bool returns the former value of slaveOkay for this instance. |
81
|
|
|
*/ |
82
|
|
|
public function setSlaveOkay($ok = true) |
83
|
|
|
{ |
84
|
|
|
$result = $this->setSlaveOkayFromParameter($ok); |
85
|
|
|
return $result; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* @deprecated Relying on this feature is highly discouraged. Please use MongoPool::setSize() instead. |
90
|
|
|
*(PECL mongo >= 1.2.0)<br/> |
91
|
|
|
* Set the size for future connection pools. |
92
|
|
|
* @link http://php.net/manual/en/mongo.setpoolsize.php |
93
|
|
|
* @param $size <p>The max number of connections future pools will be able to create. Negative numbers mean that the pool will spawn an infinite number of connections.</p> |
94
|
|
|
* @return bool Returns the former value of pool size. |
95
|
|
|
*/ |
96
|
|
|
public function setPoolSize($size) {} |
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* Creates a persistent connection with a database server |
99
|
|
|
* @link http://www.php.net/manual/en/mongo.persistconnect.php |
100
|
|
|
* @deprecated Pass array("persist" => $id) to the constructor instead of using this method. |
101
|
|
|
* @param string $username A username used to identify the connection. |
102
|
|
|
* @param string $password A password used to identify the connection. |
103
|
|
|
* @throws MongoConnectionException |
104
|
|
|
* @return boolean If the connection was successful. |
105
|
|
|
*/ |
106
|
|
|
public function persistConnect($username = "", $password = "") {} |
|
|
|
|
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* Creates a persistent connection with paired database servers |
110
|
|
|
* @deprecated Pass "mongodb://server1,server2" and array("persist" => $id) to the constructor instead of using this method. |
111
|
|
|
* @link http://www.php.net/manual/en/mongo.pairpersistconnect.php |
112
|
|
|
* @param string $username A username used to identify the connection. |
113
|
|
|
* @param string $password A password used to identify the connection. |
114
|
|
|
* @throws MongoConnectionException |
115
|
|
|
* @return boolean If the connection was successful. |
116
|
|
|
*/ |
117
|
|
|
public function pairPersistConnect($username = "", $password = "") {} |
|
|
|
|
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* Connects with a database server |
121
|
|
|
* |
122
|
|
|
* @link http://www.php.net/manual/en/mongo.connectutil.php |
123
|
|
|
* @throws MongoConnectionException |
124
|
|
|
* @return boolean If the connection was successful. |
125
|
|
|
*/ |
126
|
|
|
protected function connectUtil() {} |
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* Check if there was an error on the most recent db operation performed |
130
|
|
|
* @deprecated Use MongoDB::lastError() instead. |
131
|
|
|
* @link http://www.php.net/manual/en/mongo.lasterror.php |
132
|
|
|
* @return array|null Returns the error, if there was one, or NULL. |
133
|
|
|
*/ |
134
|
|
|
public function lastError() {} |
135
|
|
|
|
136
|
|
|
/** |
137
|
|
|
* Checks for the last error thrown during a database operation |
138
|
|
|
* @deprecated Use MongoDB::prevError() instead. |
139
|
|
|
* @link http://www.php.net/manual/en/mongo.preverror.php |
140
|
|
|
* @return array Returns the error and the number of operations ago it occurred. |
141
|
|
|
*/ |
142
|
|
|
public function prevError() {} |
143
|
|
|
|
144
|
|
|
/** |
145
|
|
|
* Clears any flagged errors on the connection |
146
|
|
|
* @deprecated Use MongoDB::resetError() instead. |
147
|
|
|
* @link http://www.php.net/manual/en/mongo.reseterror.php |
148
|
|
|
* @return array Returns the database response. |
149
|
|
|
*/ |
150
|
|
|
public function resetError() {} |
151
|
|
|
|
152
|
|
|
/** |
153
|
|
|
* Creates a database error on the database. |
154
|
|
|
* @deprecated Use MongoDB::forceError() instead. |
155
|
|
|
* @link http://www.php.net/manual/en/mongo.forceerror.php |
156
|
|
|
* @return boolean The database response. |
157
|
|
|
*/ |
158
|
|
|
public function forceError() {} |
159
|
|
|
} |
160
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.