* Fixed a bug causing the installer to ignore the "engine" and "charset" settings...
[lhc/web/wiklou.git] / includes / db / LBFactory_Single.php
1 <?php
2
3 /**
4 * An LBFactory class that always returns a single database object.
5 */
6 class LBFactory_Single extends LBFactory {
7 protected $lb;
8
9 /**
10 * @param $conf An associative array with one member:
11 * - connection: The DatabaseBase connection object
12 */
13 function __construct( $conf ) {
14 $this->lb = new LoadBalancer_Single( $conf );
15 }
16
17 function newMainLB( $wiki = false ) {
18 return $this->lb;
19 }
20
21 function getMainLB( $wiki = false ) {
22 return $this->lb;
23 }
24
25 function newExternalLB( $cluster, $wiki = false ) {
26 return $this->lb;
27 }
28
29 function &getExternalLB( $cluster, $wiki = false ) {
30 return $this->lb;
31 }
32
33 function forEachLB( $callback, $params = array() ) {
34 call_user_func_array( $callback, array_merge( array( $this->lb ), $params ) );
35 }
36 }
37
38 /**
39 * Helper class for LBFactory_Single.
40 */
41 class LoadBalancer_Single extends LoadBalancer {
42 var $db;
43
44 function __construct( $params ) {
45 $this->db = $params['connection'];
46 parent::__construct( array( 'servers' => array( array(
47 'type' => $this->db->getType(),
48 'host' => $this->db->getServer(),
49 'dbname' => $this->db->getDBname(),
50 'load' => 1,
51 ) ) ) );
52 }
53
54 function reallyOpenConnection( $server, $dbNameOverride = false ) {
55 return $this->db;
56 }
57 }