add WipeDataLoader
This commit is contained in:
parent
2be58a2cb9
commit
bb9dfbef42
3 changed files with 138 additions and 15 deletions
60
DataFixtures/Loader/WipeDataLoader.php
Normal file
60
DataFixtures/Loader/WipeDataLoader.php
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the PropelBundle package.
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @license MIT License
|
||||
*/
|
||||
|
||||
namespace Propel\PropelBundle\DataFixtures\Loader;
|
||||
|
||||
/**
|
||||
* @author Toni Uebernickel <tuebernickel@gmail.com>
|
||||
*/
|
||||
class WipeDataLoader extends AbstractDataLoader
|
||||
{
|
||||
/**
|
||||
* Clears the database completely.
|
||||
*
|
||||
* @param array $files A set of files containing datas to load.
|
||||
* @param string $connectionName The Propel connection name
|
||||
*/
|
||||
public function load($files = array(), $connectionName)
|
||||
{
|
||||
$this->loadMapBuilders($connectionName);
|
||||
|
||||
$this->con = \Propel::getConnection($connectionName);
|
||||
|
||||
try {
|
||||
$this->con->beginTransaction();
|
||||
|
||||
$tables = array();
|
||||
foreach ($this->dbMap->getTables() as $eachTable) {
|
||||
/* @var $eachTable \TableMap */
|
||||
$tables[$eachTable->getClassname()] = array();
|
||||
}
|
||||
|
||||
$this->deleteCurrentData($tables);
|
||||
|
||||
$this->con->commit();
|
||||
} catch (\Exception $e) {
|
||||
$this->con->rollBack();
|
||||
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Not used by this data loader.
|
||||
*
|
||||
* @param string $file A filename.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function transformDataToArray($file)
|
||||
{
|
||||
return array();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue