5use InvalidArgumentException;
55 } elseif ( is_array(
$conn ) && count(
$conn ) >= 4 &&
$conn[self::FLD_DOMAIN] !==
false ) {
56 $this->params =
$conn;
58 throw new InvalidArgumentException(
"Missing lazy connection arguments." );
62 function __call( $name, array $arguments ) {
63 if ( $this->conn ===
null ) {
65 $this->conn = $this->lb->getConnection( $index, $groups, $wiki, $flags );
68 return $this->conn->$name( ...$arguments );
80 return $this->
__call( __FUNCTION__, func_get_args() );
89 return $this->
__call( __FUNCTION__, func_get_args() );
93 return $this->
__call( __FUNCTION__, func_get_args() );
97 return $this->
__call( __FUNCTION__, func_get_args() );
101 return $this->
__call( __FUNCTION__, func_get_args() );
105 return $this->
__call( __FUNCTION__, func_get_args() );
109 if ( $this->conn ===
null && $prefix ===
null ) {
112 return $domain->getTablePrefix();
113 } elseif ( $this->conn !==
null && $prefix ===
null ) {
115 return $this->
__call( __FUNCTION__, func_get_args() );
122 if ( $this->conn ===
null && $schema ===
null ) {
125 return $domain->getSchema();
126 } elseif ( $this->conn !==
null && $schema ===
null ) {
128 return $this->
__call( __FUNCTION__, func_get_args() );
135 return $this->
__call( __FUNCTION__, func_get_args() );
138 public function setLBInfo( $nameOrArray, $value =
null ) {
145 throw new DBUnexpectedError( $this,
"Database injection is disallowed to enable reuse." );
149 return $this->
__call( __FUNCTION__, func_get_args() );
153 return $this->
__call( __FUNCTION__, func_get_args() );
157 return $this->
__call( __FUNCTION__, func_get_args() );
161 return $this->
__call( __FUNCTION__, func_get_args() );
165 return $this->
__call( __FUNCTION__, func_get_args() );
169 return $this->
__call( __FUNCTION__, func_get_args() );
173 return $this->
__call( __FUNCTION__, func_get_args() );
177 return $this->
__call( __FUNCTION__, func_get_args() );
181 return $this->
__call( __FUNCTION__, func_get_args() );
185 return $this->
__call( __FUNCTION__, func_get_args() );
188 public function setFlag( $flag, $remember = self::REMEMBER_NOTHING ) {
189 return $this->
__call( __FUNCTION__, func_get_args() );
192 public function clearFlag( $flag, $remember = self::REMEMBER_NOTHING ) {
193 return $this->
__call( __FUNCTION__, func_get_args() );
197 return $this->
__call( __FUNCTION__, func_get_args() );
201 return $this->
__call( __FUNCTION__, func_get_args() );
205 return $this->
__call( __FUNCTION__, func_get_args() );
209 if ( $this->conn ===
null ) {
215 return $this->
__call( __FUNCTION__, func_get_args() );
219 if ( $this->conn ===
null ) {
221 if ( $this->params[self::FLD_INDEX] === ILoadBalancer::DB_MASTER ) {
222 $index = $this->lb->getWriterIndex();
228 return $this->lb->getServerType( $index );
232 return $this->
__call( __FUNCTION__, func_get_args() );
236 return $this->
__call( __FUNCTION__, func_get_args() );
240 return $this->
__call( __FUNCTION__, func_get_args() );
244 return $this->
__call( __FUNCTION__, func_get_args() );
248 return $this->
__call( __FUNCTION__, func_get_args() );
252 return $this->
__call( __FUNCTION__, func_get_args() );
256 return $this->
__call( __FUNCTION__, func_get_args() );
260 return $this->
__call( __FUNCTION__, func_get_args() );
264 return $this->
__call( __FUNCTION__, func_get_args() );
268 return $this->
__call( __FUNCTION__, func_get_args() );
272 return $this->
__call( __FUNCTION__, func_get_args() );
276 return $this->
__call( __FUNCTION__, func_get_args() );
280 return $this->
__call( __FUNCTION__, func_get_args() );
283 public function close( $fname = __METHOD__, $owner =
null ) {
287 public function query( $sql, $fname = __METHOD__, $flags = 0 ) {
288 if ( $this->role !== ILoadBalancer::DB_MASTER ) {
289 $flags |= IDatabase::QUERY_REPLICA_ROLE;
292 return $this->
__call( __FUNCTION__, [ $sql, $fname, $flags ] );
296 return $this->
__call( __FUNCTION__, func_get_args() );
300 $table, $var, $cond =
'', $fname = __METHOD__, $options = [], $join_conds = []
302 return $this->
__call( __FUNCTION__, func_get_args() );
306 $table, $var, $cond =
'', $fname = __METHOD__, $options = [], $join_conds = []
308 return $this->
__call( __FUNCTION__, func_get_args() );
312 $table, $vars, $conds =
'', $fname = __METHOD__,
313 $options = [], $join_conds = []
315 return $this->
__call( __FUNCTION__, func_get_args() );
319 $table, $vars, $conds =
'', $fname = __METHOD__,
320 $options = [], $join_conds = []
322 return $this->
__call( __FUNCTION__, func_get_args() );
326 return $this->
__call( __FUNCTION__, func_get_args() );
330 $table, $vars, $conds, $fname = __METHOD__,
331 $options = [], $join_conds = []
333 return $this->
__call( __FUNCTION__, func_get_args() );
337 $table, $vars =
'*', $conds =
'', $fname = __METHOD__, $options = [], $join_conds = []
339 return $this->
__call( __FUNCTION__, func_get_args() );
343 $tables, $vars =
'*', $conds =
'', $fname = __METHOD__, $options = [], $join_conds = []
345 return $this->
__call( __FUNCTION__, func_get_args() );
349 $table, $conds =
'', $fname = __METHOD__, $options = [], $join_conds = []
353 return $this->
__call( __FUNCTION__, func_get_args() );
356 public function fieldExists( $table, $field, $fname = __METHOD__ ) {
357 return $this->
__call( __FUNCTION__, func_get_args() );
360 public function indexExists( $table, $index, $fname = __METHOD__ ) {
361 return $this->
__call( __FUNCTION__, func_get_args() );
365 return $this->
__call( __FUNCTION__, func_get_args() );
368 public function insert( $table, $a, $fname = __METHOD__, $options = [] ) {
371 return $this->
__call( __FUNCTION__, func_get_args() );
374 public function update( $table, $values, $conds, $fname = __METHOD__, $options = [] ) {
377 return $this->
__call( __FUNCTION__, func_get_args() );
380 public function makeList( $a, $mode = self::LIST_COMMA ) {
381 return $this->
__call( __FUNCTION__, func_get_args() );
385 return $this->
__call( __FUNCTION__, func_get_args() );
389 return $this->
__call( __FUNCTION__, func_get_args() );
393 return $this->
__call( __FUNCTION__, func_get_args() );
396 public function bitAnd( $fieldLeft, $fieldRight ) {
397 return $this->
__call( __FUNCTION__, func_get_args() );
400 public function bitOr( $fieldLeft, $fieldRight ) {
401 return $this->
__call( __FUNCTION__, func_get_args() );
405 return $this->
__call( __FUNCTION__, func_get_args() );
409 $delim, $table, $field, $conds =
'', $join_conds = []
411 return $this->
__call( __FUNCTION__, func_get_args() );
415 return $this->
__call( __FUNCTION__, func_get_args() );
419 return $this->
__call( __FUNCTION__, func_get_args() );
423 return $this->
__call( __FUNCTION__, func_get_args() );
427 $table, $vars, $conds =
'', $fname = __METHOD__,
428 $options = [], $join_conds = []
430 return $this->
__call( __FUNCTION__, func_get_args() );
434 return $this->
__call( __FUNCTION__, func_get_args() );
448 if ( $this->conn ===
null ) {
451 return $domain->getDatabase();
454 return $this->
__call( __FUNCTION__, func_get_args() );
458 return $this->
__call( __FUNCTION__, func_get_args() );
462 return $this->
__call( __FUNCTION__, func_get_args() );
466 return $this->
__call( __FUNCTION__, func_get_args() );
470 return $this->
__call( __FUNCTION__, func_get_args() );
474 return $this->
__call( __FUNCTION__, func_get_args() );
478 return $this->
__call( __FUNCTION__, func_get_args() );
484 return $this->
__call( __FUNCTION__, func_get_args() );
487 public function replace( $table, $uniqueIndexes, $rows, $fname = __METHOD__ ) {
490 return $this->
__call( __FUNCTION__, func_get_args() );
494 $table, array $rows, $uniqueIndexes, array $set, $fname = __METHOD__
498 return $this->
__call( __FUNCTION__, func_get_args() );
502 $delTable, $joinTable, $delVar, $joinVar, $conds, $fname = __METHOD__
506 return $this->
__call( __FUNCTION__, func_get_args() );
509 public function delete( $table, $conds, $fname = __METHOD__ ) {
512 return $this->
__call( __FUNCTION__, func_get_args() );
516 $destTable, $srcTable, $varMap, $conds,
517 $fname = __METHOD__, $insertOptions = [], $selectOptions = [], $selectJoinConds = []
521 return $this->
__call( __FUNCTION__, func_get_args() );
525 return $this->
__call( __FUNCTION__, func_get_args() );
529 return $this->
__call( __FUNCTION__, func_get_args() );
533 $table, $vars, array $permute_conds, $extra_conds =
'', $fname = __METHOD__,
534 $options = [], $join_conds = []
536 return $this->
__call( __FUNCTION__, func_get_args() );
540 return $this->
__call( __FUNCTION__, func_get_args() );
544 return $this->
__call( __FUNCTION__, func_get_args() );
548 return $this->
__call( __FUNCTION__, func_get_args() );
552 return $this->
__call( __FUNCTION__, func_get_args() );
556 return $this->
__call( __FUNCTION__, func_get_args() );
560 return $this->
__call( __FUNCTION__, func_get_args() );
564 return $this->
__call( __FUNCTION__, func_get_args() );
568 return $this->
__call( __FUNCTION__, func_get_args() );
572 return $this->
__call( __FUNCTION__, func_get_args() );
576 return $this->
__call( __FUNCTION__, func_get_args() );
580 return $this->
__call( __FUNCTION__, func_get_args() );
584 return $this->
__call( __FUNCTION__, func_get_args() );
589 return $this->
__call( __FUNCTION__, func_get_args() );
594 return $this->
__call( __FUNCTION__, func_get_args() );
603 return $this->
__call( __FUNCTION__, func_get_args() );
607 return $this->
__call( __FUNCTION__, func_get_args() );
611 return $this->
__call( __FUNCTION__, func_get_args() );
615 $fname = __METHOD__, $cancelable = IDatabase::ATOMIC_NOT_CANCELABLE
618 return $this->
__call( __FUNCTION__, func_get_args() );
623 return $this->
__call( __FUNCTION__, func_get_args() );
628 return $this->
__call( __FUNCTION__, func_get_args() );
632 $fname, callable $callback, $cancelable = self::ATOMIC_NOT_CANCELABLE
635 return $this->
__call( __FUNCTION__, func_get_args() );
638 public function begin( $fname = __METHOD__, $mode = IDatabase::TRANSACTION_EXPLICIT ) {
639 return $this->
__call( __FUNCTION__, func_get_args() );
642 public function commit( $fname = __METHOD__, $flush = self::FLUSHING_ONE ) {
643 return $this->
__call( __FUNCTION__, func_get_args() );
646 public function rollback( $fname = __METHOD__, $flush = self::FLUSHING_ONE ) {
647 return $this->
__call( __FUNCTION__, func_get_args() );
650 public function flushSnapshot( $fname = __METHOD__, $flush = self::FLUSHING_ONE ) {
651 return $this->
__call( __FUNCTION__, func_get_args() );
655 return $this->
__call( __FUNCTION__, func_get_args() );
659 return $this->
__call( __FUNCTION__, func_get_args() );
662 public function ping( &$rtt =
null ) {
663 return func_num_args()
664 ? $this->
__call( __FUNCTION__, [ &$rtt ] )
665 : $this->
__call( __FUNCTION__, [] );
669 return $this->
__call( __FUNCTION__, func_get_args() );
673 return $this->
__call( __FUNCTION__, func_get_args() );
677 return $this->
__call( __FUNCTION__, func_get_args() );
681 return $this->
__call( __FUNCTION__, func_get_args() );
685 return $this->
__call( __FUNCTION__, func_get_args() );
689 return $this->
__call( __FUNCTION__, func_get_args() );
693 return $this->
__call( __FUNCTION__, func_get_args() );
699 return $this->
__call( __FUNCTION__, func_get_args() );
702 public function lock( $lockName, $method, $timeout = 5 ) {
705 return $this->
__call( __FUNCTION__, func_get_args() );
708 public function unlock( $lockName, $method ) {
711 return $this->
__call( __FUNCTION__, func_get_args() );
717 return $this->
__call( __FUNCTION__, func_get_args() );
721 return $this->
__call( __FUNCTION__, func_get_args() );
725 return $this->
__call( __FUNCTION__, func_get_args() );
729 return $this->
__call( __FUNCTION__, func_get_args() );
733 return $this->
__call( __FUNCTION__, func_get_args() );
737 return $this->
__call( __FUNCTION__, func_get_args() );
741 return $this->
__call( __FUNCTION__, func_get_args() );
745 return $this->
__call( __FUNCTION__, func_get_args() );
749 return $this->
__call( __FUNCTION__, func_get_args() );
753 if ( $this->conn ===
null ) {
755 $id = function_exists(
'spl_object_id' )
756 ? spl_object_id( $this )
757 : spl_object_hash( $this );
759 return $this->
getType() .
' object #' . $id;
762 return $this->
__call( __FUNCTION__, func_get_args() );
780 if ( $this->role !== ILoadBalancer::DB_MASTER ) {
791 "Cannot directly change the selected DB domain; any underlying connection handle " .
792 "is owned by a LoadBalancer instance and possibly shared with other callers. " .
793 "LoadBalancer automatically manages DB domain re-selection of unused handles."
802 $this->lb->reuseConnection( $this->conn );
811class_alias( DBConnRef::class,
'DBConnRef' );
Class to handle database/schema/prefix specifications for IDatabase.
static newFromId( $domain)