public function setUp() { $dumper = new CDumper(); $content = file_get_contents(dirname(__FILE__) . '/import.sql'); $dumper->import($content); $this->clearSystemRegister(); }
<?php require_once dirname(__FILE__) . '/../_cfg/mysql_connect.php'; require_once dirname(__FILE__) . '/../3.2/class/dumper/dumper.class.php'; set_time_limit(0); $dumper = new CDumper(); $szContent = file_get_contents('./original-dump.sql'); $dumper->import($szContent); print 'Database restored' . "\r\n"; $path = dirname(__FILE__) . '/../_cache/system_register_get'; if (file_exists($path)) { unlink($path); } $path = dirname(__FILE__) . '/../_cache/system_register_child'; if (file_exists($path)) { unlink($path); } print 'System Register cache cleared' . "\r\n";
/** * @author Gisma * Импортирует файл-дампа в бд */ public static function importFile($szFileName) { $dumper = new CDumper(); $dumper->import(file_get_contents($szFileName)); }
/** * ------------------------------------------------------------------------------------------- * Импортирует SQL-console * @return * ------------------------------------------------------------------------------------------- */ public function import() { if (!empty($_FILES['file'])) { $fs = DAO_FileSystem::getInstance(); $fs->upload('file', FILE_PATH . 'import.sql'); if (file_exists(FILE_PATH . 'import.sql')) { $szImport = file_get_contents(FILE_PATH . 'import.sql'); $dumper = new CDumper(); $szDump = $dumper->import($szImport); $this->addAlert('Файл импортирован'); } } $this->jump('sql.php'); }
<?php use Extasy\tests\Helper; \Extasy\tests\system_register\Restorator::restore(); require_once CLASS_PATH . 'dumper/dumper.class.php'; $sql = <<<SQL \tDROP TABLE IF EXISTS acl_actions ; \tDROP TABLE IF EXISTS acl_grants; \tCREATE TABLE acl_actions ( \t\t`id` INT NOT NULL auto_increment, \t\t`name` varchar(40) not null COMMENT 'Имя события', \t\t`title` varchar(80) null COMMENT 'Подпись к событию', \t\t`parentId` int not null, \t\t`fullPath` varchar(255) not null, \t\tPRIMARY KEY (`id`), \t\tindex `searchParent` (`parentId`), \t\tindex `searchChild` (`parentId`,`name`), \t\tindex `searchPath` (`fullPath`) \t); \tCREATE TABLE acl_grants ( \t\t`actionId` int not null COMMENT 'Индекс события', \t\t`entity` varchar(80) not null COMMENT 'Имя объекта', \t\t unique `search` (`actionId`,`entity`), \t\t index search_by_entity (`entity`) \t); SQL; $dumper = new CDumper(); $dumper->import($sql);