MediaWiki  REL1_19
CloneDatabase Class Reference

Helper class for making a copy of the database, mostly for unit testing. More...

List of all members.

Public Member Functions

 __construct (DatabaseBase $db, array $tablesToClone, $newTablePrefix, $oldTablePrefix= '', $dropCurrentTables=true)
 Constructor.
 cloneTableStructure ()
 Clone the table structure.
 destroy ($dropTables=false)
 Change the prefix back to the original.
 useTemporaryTables ($u=true)
 Set whether to use temporary tables or not.

Static Public Member Functions

static changeDBPrefix ($db, $prefix)
static changeLBPrefix ($lb, $prefix)
static changePrefix ($prefix)
 Change the table prefix on all open DB connections/.

Private Attributes

 $dropCurrentTables = true
 $newTablePrefix = ''
 $oldTablePrefix = ''
 $tablesToClone = array()
 $useTemporaryTables = true

Detailed Description

Helper class for making a copy of the database, mostly for unit testing.

Copyright © 2010 Chad Horohoe <[email protected]> http://www.mediawiki.org/

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. http://www.gnu.org/copyleft/gpl.html

Definition at line 26 of file CloneDatabase.php.


Constructor & Destructor Documentation

CloneDatabase::__construct ( DatabaseBase db,
array $  tablesToClone,
newTablePrefix,
oldTablePrefix = '',
dropCurrentTables = true 
)

Constructor.

Parameters:
$dbDatabaseBase A database subclass
$tablesToCloneArray An array of tables to clone, unprefixed
$newTablePrefixString Prefix to assign to the tables
$oldTablePrefixString Prefix on current tables, if not $wgDBprefix
$dropCurrentTablesbool

Definition at line 67 of file CloneDatabase.php.

References $dropCurrentTables, $newTablePrefix, $oldTablePrefix, and $tablesToClone.


Member Function Documentation

static CloneDatabase::changeDBPrefix ( db,
prefix 
) [static]
Parameters:
$dbDatabaseBase
$prefix
Returns:
void

Definition at line 155 of file CloneDatabase.php.

static CloneDatabase::changeLBPrefix ( lb,
prefix 
) [static]
Parameters:
$lbLoadBalancer
$prefix
Returns:
void

Definition at line 146 of file CloneDatabase.php.

References $lb.

static CloneDatabase::changePrefix ( prefix) [static]

Change the table prefix on all open DB connections/.

Parameters:
$prefix
Returns:
void

Definition at line 135 of file CloneDatabase.php.

References $wgDBprefix, and wfGetLBFactory().

Referenced by cloneTableStructure(), destroy(), and MediaWikiTestCase\initDB().

Here is the call graph for this function:

Here is the caller graph for this function:

Clone the table structure.

Definition at line 88 of file CloneDatabase.php.

References changePrefix(), useTemporaryTables(), and wfDebug().

Here is the call graph for this function:

CloneDatabase::destroy ( dropTables = false)

Change the prefix back to the original.

Parameters:
$dropTablesbool Optionally drop the tables we created

Definition at line 119 of file CloneDatabase.php.

References changePrefix().

Here is the call graph for this function:

Set whether to use temporary tables or not.

Parameters:
$uBool Use temporary tables when cloning the structure

Definition at line 81 of file CloneDatabase.php.

Referenced by cloneTableStructure().

Here is the caller graph for this function:


Member Data Documentation

CloneDatabase::$dropCurrentTables = true [private]

Definition at line 50 of file CloneDatabase.php.

Referenced by __construct().

CloneDatabase::$newTablePrefix = '' [private]

Definition at line 32 of file CloneDatabase.php.

Referenced by __construct().

CloneDatabase::$oldTablePrefix = '' [private]

Definition at line 38 of file CloneDatabase.php.

Referenced by __construct().

CloneDatabase::$tablesToClone = array() [private]

Definition at line 44 of file CloneDatabase.php.

Referenced by __construct().

CloneDatabase::$useTemporaryTables = true [private]

Definition at line 56 of file CloneDatabase.php.


The documentation for this class was generated from the following file: