[ Index ] |
PHP Cross Reference of MediaWiki-1.24.0 |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * Base class for objects that allow access to other wiki's databases using 5 * the foreign database access mechanism implemented by LBFactoryMulti. 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; either version 2 of the License, or 10 * (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License along 18 * with this program; if not, write to the Free Software Foundation, Inc., 19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * http://www.gnu.org/copyleft/gpl.html 21 * 22 * @since 1.21 23 * 24 * @file 25 * @ingroup Database 26 * 27 * @licence GNU GPL v2+ 28 * @author Daniel Kinzler 29 */ 30 abstract class DBAccessBase implements IDBAccessObject { 31 /** 32 * @var string|bool $wiki The target wiki's name. This must be an ID 33 * that LBFactory can understand. 34 */ 35 protected $wiki = false; 36 37 /** 38 * @param string|bool $wiki The target wiki's name. This must be an ID 39 * that LBFactory can understand. 40 */ 41 public function __construct( $wiki = false ) { 42 $this->wiki = $wiki; 43 } 44 45 /** 46 * Returns a database connection. 47 * 48 * @see wfGetDB() 49 * @see LoadBalancer::getConnection() 50 * 51 * @since 1.21 52 * 53 * @param int $id Which connection to use 54 * @param array $groups Query groups 55 * 56 * @return DatabaseBase 57 */ 58 protected function getConnection( $id, $groups = array() ) { 59 $loadBalancer = wfGetLB( $this->wiki ); 60 61 return $loadBalancer->getConnection( $id, $groups, $this->wiki ); 62 } 63 64 /** 65 * Releases a database connection and makes it available for recycling. 66 * 67 * @see LoadBalancer::reuseConnection() 68 * 69 * @since 1.21 70 * 71 * @param DatabaseBase $db The database connection to release. 72 */ 73 protected function releaseConnection( DatabaseBase $db ) { 74 if ( $this->wiki !== false ) { 75 $loadBalancer = $this->getLoadBalancer(); 76 $loadBalancer->reuseConnection( $db ); 77 } 78 } 79 80 /** 81 * Get the database type used for read operations. 82 * 83 * @see wfGetLB 84 * 85 * @since 1.21 86 * 87 * @return LoadBalancer The database load balancer object 88 */ 89 public function getLoadBalancer() { 90 return wfGetLB( $this->wiki ); 91 } 92 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 14:03:12 2014 | Cross-referenced by PHPXref 0.7.1 |