Return translated SQL content using tpl, mainly contain SQL codes on table CREATE/DROP

@param string $srcPath
@param array $database
@param array $tables
@return string
964134
public static function generateCreateSql($srcPath, $database, $tables) {
    $template = new Template($srcPath, 'sql');

    $template->assign('database', $database);
    $template->assign('tables', $tables);
    $dropOrder = array_reverse(array_keys($tables));
    $template->assign('dropOrder', $dropOrder);
    $template->assign('mysql', 'modern');

    return $template->getContent('schema.tpl');
  }
98961
public function getMigrationTableDDL(TableDiff $tableDiff)
    {
        $pattern = "
CREATE TEMPORARY TABLE %s AS SELECT %s FROM %s;
DROP TABLE %s;
%s
INSERT INTO %s (%s) SELECT %s FROM %s;
DROP TABLE %s;
";

        $originTable     = clone $tableDiff->getFromTable();
        $newTable        = clone $tableDiff->getToTable();

        $originTableName = $originTable->getName();
        $tempTableName   = $newTable->getCommonName().'__temp__'.uniqid();

        $originTableFields = $this->getColumnListDDL($originTable->getColumns());

        $fieldMap = []; /** struct: [<oldCol> => <newCol>] */
        //start with modified columns
        foreach ($tableDiff->getModifiedColumns() as $diff) {
            $fieldMap[$diff->getFromColumn()->getName()] = $diff->getToColumn()->getName();
        }

        foreach ($tableDiff->getRenamedColumns() as $col) {
            list ($from, $to) = $col;
            $fieldMap[$from->getName()] = $to->getName();
        }

        foreach ($newTable->getColumns() as $col) {
            if ($originTable->hasColumn($col)) {
                if (!isset($fieldMap[$col->getName()])) {
                    $fieldMap[$col->getName()] = $col->getName();
                }
            }

        }

        $createTable = $this->getAddTableDDL($newTable);
        $createTable .= $this->getAddIndicesDDL($newTable);

        $sql = sprintf($pattern,
            $this->quoteIdentifier($tempTableName), //CREATE TEMPORARY TABLE %s
            $originTableFields, //select %s
            $this->quoteIdentifier($originTableName), //from %s
            $this->quoteIdentifier($originTableName), //drop table %s
            $createTable, //[create table] %s
            $this->quoteIdentifier($originTableName), //insert into %s
            implode(', ', $fieldMap), //(%s)
            implode(', ', array_keys($fieldMap)), //select %s
            $this->quoteIdentifier($tempTableName), //from %s
            $this->quoteIdentifier($tempTableName) //drop table %s
        );

        return $sql;
    }
638842
function backup_tables($file, $compress = false, $tables = null)
    {

        $this->conn->setAttribute(PDO::ATTR_ORACLE_NULLS, PDO::NULL_TO_STRING);

//Script Variables
        $compression = $compress;
        $BACKUP_PATH = $file;


//create/open files
        if ($compression) {
            $zp = gzopen($BACKUP_PATH .'', "w9");
        } else {
            $handle = fopen($BACKUP_PATH , 'a+');
        }


//array of all database field types which just take numbers 
        $numtypes = array('tinyint', 'smallint', 'mediumint', 'int', 'bigint', 'float', 'double', 'decimal', 'real');

//get all of the tables
        if (empty($tables)) {
            $pstm1 = $this->conn->query('SHOW TABLES');
            while ($row = $pstm1->fetch(PDO::FETCH_NUM)) {
                $tables[] = $row[0];
            }
        } else {
            $tables = is_array($tables) ? $tables : explode(',', $tables);
        }

//cycle through the table(s)

        foreach ($tables as $table) {
            $result = $this->conn->query('SELECT * FROM ' . $table);
            $num_fields = $result->columnCount();
            $num_rows = $result->rowCount();

            $return = "";
//uncomment below if you want 'DROP TABLE IF EXISTS' displayed
//$return.= 'DROP TABLE IF EXISTS `'.$table.'`;'; 


//table structure
            $pstm2 = $this->conn->query('SHOW CREATE TABLE ' . $table);
            $row2 = $pstm2->fetch(PDO::FETCH_NUM);
            $ifnotexists = str_replace('CREATE TABLE', 'CREATE TABLE IF NOT EXISTS', $row2[1]);
            $return .= "\n\n" . $ifnotexists . ";\n\n";


            if ($compression) {
                gzwrite($zp, $return);
            } else {
                fwrite($handle, $return);
            }
            $return = "";

//insert values
            if ($num_rows) {
                $return = 'INSERT INTO `' . $table . "` (";
                $pstm3 = $this->conn->query('SHOW COLUMNS FROM ' . $table);
                $count = 0;
                $type = array();

                while ($rows = $pstm3->fetch(PDO::FETCH_NUM)) {

                    if (stripos($rows[1], '(')) {
                        $type[$table][] = stristr($rows[1], '(', true);
                    } else $type[$table][] = $rows[1];

                    $return .= $rows[0];
                    $count++;
                    if ($count < ($pstm3->rowCount())) {
                        $return .= ", ";
                    }
                }

                $return .= ")" . ' VALUES';

                if ($compression) {
                    gzwrite($zp, $return);
                } else {
                    fwrite($handle, $return);
                }
                $return = "";
            }

            while ($row = $result->fetch(PDO::FETCH_NUM)) {
                $return = "\n\t(";
                for ($j = 0; $j < $num_fields; $j++) {
                    $row[$j] = addslashes($row[$j]);
//$row[$j] = preg_replace("\n","\\n",$row[$j]);


                    if (isset($row[$j])) {
//if number, take away "". else leave as string
                        if (in_array($type[$table][$j], $numtypes)) $return .= $row[$j]; else $return .= '"' . $row[$j] . '"';
                    } else {
                        $return .= '""';
                    }
                    if ($j < ($num_fields - 1)) {
                        $return .= ',';
                    }
                }
                $count++;
                if ($count < ($result->rowCount())) {
                    $return .= "),";
                } else {
                    $return .= ");";

                }
                if ($compression) {
                    gzwrite($zp, $return);
                } else {
                    fwrite($handle, $return);
                }
                $return = "";
            }
            $return = "\n\n-- ------------------------------------------------ \n\n";
            if ($compression) {
                gzwrite($zp, $return);
            } else {
                fwrite($handle, $return);
            }
            $return = "";
        }


        $error1 = $pstm2->errorInfo();
        $error2 = $pstm3->errorInfo();
        $error3 = $result->errorInfo();
        echo $error1[2];
        echo $error2[2];
        echo $error3[2];

        if ($compression) {
            gzclose($zp);
        } else {
            fclose($handle);
        }
    }
1217516
public function getDeleteSQL($from, $joins, $where, $values, $order, $limit) {
        $len    = count($joins);
        $jw     = [];
        $sql [] = 'DELETE FROM ' . implode(' AS ', $from [0]);
        if ($len) {
            $sql [] = 'USING';

            foreach ($joins as $join) {
                $jw[]   = $join[1];
                $sql [] = $join [0] . ' AS ' . $join [3];
            }
        }

        if ($where && count($where) > 0) {
            $sql [] = 'WHERE';
            $sql [] = $where->getWhereCondition($this, $values);
        }
        if ($jw) {
            if ($where && count($where) > 0) {
                $sql[] = 'AND ' . implode(' AND ', $jw);
            } else {
                $sql[] = 'WHERE ' . implode(' AND ', $jw);
            }
        }

        return implode(' ', $sql);
    }
936127
public static function getTables($statement)
    {
        $expressions = [];

        if (($statement instanceof InsertStatement)
            || ($statement instanceof ReplaceStatement)
        ) {
            $expressions = [$statement->into->dest];
        } elseif ($statement instanceof UpdateStatement) {
            $expressions = $statement->tables;
        } elseif (($statement instanceof SelectStatement)
            || ($statement instanceof DeleteStatement)
        ) {
            $expressions = $statement->from;
        } elseif (($statement instanceof AlterStatement)
            || ($statement instanceof TruncateStatement)
        ) {
            $expressions = [$statement->table];
        } elseif ($statement instanceof DropStatement) {
            if (! $statement->options->has('TABLE')) {
                // No tables are dropped.
                return [];
            }
            $expressions = $statement->fields;
        } elseif ($statement instanceof RenameStatement) {
            foreach ($statement->renames as $rename) {
                $expressions[] = $rename->old;
            }
        }

        $ret = [];
        foreach ($expressions as $expr) {
            if (! empty($expr->table)) {
                $expr->expr = null; // Force rebuild.
                $expr->alias = null; // Aliases are not required.
                $ret[] = Expression::build($expr);
            }
        }

        return $ret;
    }
722948
private function processCols(array $tables, Config $config)
    {
        if ($config['cols']) {
            $cols = $config['cols'];

            if ($config['compare']) {
                $cols[] = $config['compare'];
                $cols = array_merge($cols, $config['compare_fields']);
            }
            $tables = F\map($tables, function ($table) use ($cols) {
                return F\map($table, function ($row) use ($cols) {
                    $newRow = $row->newInstance([]);

                    foreach ($cols as $col) {
                        if ($col === 'diff') {
                            continue;
                        }
                        $newRow[$col] = $row[$col];
                    }

                    return $newRow;
                });
            });
        }

        return $tables;
    }
140346
public function dump()
    {
        $return = '';
        
        if (count($this->tables) == 0)
        {
            $this->addAllTables();
        }
        
        $return .= "--\n";
        $return .= "-- Backup ".$this->db['name']." - ".date('Y-m-d H:i:s')."\n";
        $return .= "--\n\n\n";
        
        $return .= "SET FOREIGN_KEY_CHECKS=0;";
        $return .= "\n\n\n";

        if ($this->addCreateDatabaseIfNotExists === true)
        {
            $return .= "CREATE DATABASE IF NOT EXISTS `".$this->db['name']."`;\n";
            $return .= "USE `".$this->db['name']."`;";
            $return .= "\n\n\n";
        }
        
        foreach ($this->tables as $table)
        {
            // We skip excluded tables
            if (in_array($table, $this->excludedTables))
                continue;

            $stmt = $this->dbh->query('SELECT * FROM `'.$table.'`');
            $stmt->execute();
            $num_fields = $stmt->columnCount();
            
            $return .= "--\n";
            $return .= "-- Table ".$table."\n";
            $return .= "--\n\n";
            
            // Dump structure ?
            if ($this->dumpStructure === true)
            {
                // Add DROP TABLE ?
                if ($this->addDropTable === true)
                {
                    $return .= 'DROP TABLE IF EXISTS `'.$table.'`;';
                    $return .= "\n\n";
                }

                $create_table_q = $this->query('SHOW CREATE TABLE `'.$table.'`', false);
                $create_table = $create_table_q[1];
                
                // Add IF NOT EXISTS ?
                if ($this->addIfNotExists === true)
                {
                    $create_table = preg_replace('/^CREATE TABLE/', 'CREATE TABLE IF NOT EXISTS', $create_table);
                }
                
                $return .= $create_table.";\n\n";
            }
            
            // Dump datas ?
            if ($this->dumpDatas === true)
            {
                $datas = $this->query('SELECT * FROM `'.$table.'`');

                foreach ($datas as $row)
                {
                    $return .= 'INSERT INTO `'.$table.'` VALUES(';
                    
                    for ($i = 0; $i < $num_fields; $i++) 
                    {
                        if (isset($row[$i]))
                        {
                            $row[$i] = addslashes($row[$i]);
                            
                            $return .= '"'.$row[$i].'"';
                        }
                        else
                        {
                            $return .= '""';
                        }
                        
                        if ($i < ($num_fields-1))
                        {
                            $return .= ', ';
                        }
                    }
                    
                    $return .= ");\n";
                }
            }
            
            $return .= "\n\n";
            $return .= "-- --------------------------------------------------------";
            $return .= "\n\n\n";
        }
        
        
        // Save content in file
        file_put_contents($this->filename.'.'.$this->extension, $return);
        
        
        // Zip the file ?
        if (!is_null($this->compressFormat))
        {
            $this->compress();
        }
        
        // Download the file ?
        if ($this->downloadFile === true)
        {
            $this->download();
        }
        
        // Delete the file ?
        if ($this->deleteFile === true)
        {
            $this->delete();
        }
    }
588643
public function getDropSchemaSQL(array $classes)
    {
        $visitor = new DropSchemaSqlCollector($this->platform);
        $schema  = $this->getSchemaFromMetadata($classes);

        $sm         = $this->em->getConnection()->getSchemaManager();
        $fullSchema = $sm->createSchema();

        foreach ($fullSchema->getTables() as $table) {
            if (! $schema->hasTable($table->getName())) {
                foreach ($table->getForeignKeys() as $foreignKey) {
                    /** @var $foreignKey \Doctrine\DBAL\Schema\ForeignKeyConstraint */
                    if ($schema->hasTable($foreignKey->getForeignTableName())) {
                        $visitor->acceptForeignKey($table, $foreignKey);
                    }
                }
            } else {
                $visitor->acceptTable($table);
                foreach ($table->getForeignKeys() as $foreignKey) {
                    $visitor->acceptForeignKey($table, $foreignKey);
                }
            }
        }

        if ($this->platform->supportsSequences()) {
            foreach ($schema->getSequences() as $sequence) {
                $visitor->acceptSequence($sequence);
            }

            foreach ($schema->getTables() as $table) {
                /** @var $sequence Table */
                if ($table->hasPrimaryKey()) {
                    $columns = $table->getPrimaryKey()->getColumns();
                    if (count($columns) === 1) {
                        $checkSequence = $table->getName() . '_' . $columns[0] . '_seq';
                        if ($fullSchema->hasSequence($checkSequence)) {
                            $visitor->acceptSequence($fullSchema->getSequence($checkSequence));
                        }
                    }
                }
            }
        }

        return $visitor->getQueries();
    }
924397
protected function joins(array $joins): string
	{
		if(empty($joins))
		{
			return '';
		}

		$sql = [];

		foreach($joins as $join)
		{
			$sql[] = $join->getType() . ' JOIN ' . $this->table($join->getTable()) . ' ON ' . $this->joinConditions($join);
		}

		return ' ' . implode(' ', $sql);
	}
674982
protected function getDropSqlStatementsForExistingSchema(
        Schema $newSchema,
        AbstractPlatform $databasePlatform
    ): array {
        $existingSchema = $this->db->getSchemaManager()->createSchema();
        $statements = [];
        // reverse table order for clean-up (due to FKs)
        $tables = array_reverse($newSchema->getTables());
        // cleanup pre-existing database
        foreach ($tables as $table) {
            if ($existingSchema->hasTable($table->getName())) {
                $statements[] = $databasePlatform->getDropTableSQL($table);
            }
        }

        return $statements;
    }
211996
private function getTableData($tables)
    {
        $db = \OxidEsales\Eshop\Core\DatabaseProvider::getMaster(\OxidEsales\Eshop\Core\DatabaseProvider::FETCH_MODE_ASSOC);

        $data = array();
        foreach ($tables as $table) {
            $data[$table] = array();

            $result = $db->select("SELECT * FROM `${table}`");
            if ($result && $result->count() > 0) {

                $rows = array();
                while (!$result->EOF) {
                    $rows[] = $result->fields;

                    $result->fetchRow();
                }
                $data[$table]["_sql_"] = $this->getInsertString($rows, $table);
            }
        }

        return $data;
    }
620697
public function database(array $tables)
    {
        $views    = [];
        $others   = [];
        $messages = [];
        foreach ($tables as $table) {
            ($table->Comment == 'VIEW') ?
                            array_push($views, [
                                'name' => $table->Name
                            ]) :
                            array_push($others, [
                                'name'        => $table->Name,
                                'rows'        => $table->Rows,
                                'create_time' => $table->Create_time,
                                'collation'   => $table->Collation,
                                'size'        => $this->formatSize($table->Data_length + $table->Index_length)
            ]);
            if ($table->Rows > 1000) {
                array_push($messages, ['warning', sprintf('Table %s has too many data. Clean table historical entities to increase system performance.', $table->Name)]);
            }
        }
        return $this->view('database', ['views' => $views] + ['tables' => $others] + ['messages' => $messages]);
    }
164800
public function passStatementBlock(array $statements)
    {
        foreach ($statements as $statement) {
            switch ($statement['type']) {
                case 'let':
                    $this->passLetStatement($statement);
                    break;

                case 'echo':
                    if (isset($statement['expressions'])) {
                        foreach ($statement['expressions'] as $expr) {
                            $this->passExpression($expr);
                        }
                    }
                    break;

                case 'declare':
                    $this->declareVariables($statement);
                    break;

                case 'if':
                    if (isset($statement['expr'])) {
                        $this->passExpression($statement['expr']);
                    }
                    if (isset($statement['statements'])) {
                        $this->passStatementBlock($statement['statements']);
                    }
                    if (isset($statement['else_statements'])) {
                        $this->passStatementBlock($statement['else_statements']);
                    }
                    if (isset($statement['elseif_statements'])) {
                        $this->passStatementBlock($statement['elseif_statements']);
                    }
                    break;

                case 'switch':
                    if (isset($statement['expr'])) {
                        $this->passExpression($statement['expr']);
                    }
                    if (isset($statement['clauses'])) {
                        foreach ($statement['clauses'] as $clause) {
                            if (isset($clause['expr'])) {
                                $this->passExpression($clause['expr']);
                            }
                            if (isset($clause['statements'])) {
                                $this->passStatementBlock($clause['statements']);
                            }
                        }
                    }
                    break;

                case 'while':
                case 'do-while':
                    if (isset($statement['expr'])) {
                        $this->passExpression($statement['expr']);
                    }
                    if (isset($statement['statements'])) {
                        $this->passStatementBlock($statement['statements']);
                    }
                    break;

                case 'for':
                    if (isset($statement['expr'])) {
                        $this->passExpression($statement['expr']);
                    }
                    if (isset($statement['value'])) {
                        $this->increaseMutations($statement['value']);
                    }
                    if (isset($statement['key'])) {
                        $this->increaseMutations($statement['key']);
                    }
                    if (isset($statement['statements'])) {
                        $this->passStatementBlock($statement['statements']);
                    }
                    break;

                case 'return':
                    if (isset($statement['expr'])) {
                        $this->passExpression($statement['expr']);
                    }
                    break;

                case 'loop':
                    if (isset($statement['statements'])) {
                        $this->passStatementBlock($statement['statements']);
                    }
                    break;

                case 'try-catch':
                    if (isset($statement['statements'])) {
                        $this->passStatementBlock($statement['statements']);
                    }
                    if (isset($statement['catches'])) {
                        foreach ($statement['catches'] as $catch) {
                            if (isset($catch['variable'])) {
                                $this->increaseMutations($catch['variable']['value']);
                            }
                            if (isset($catch['statements'])) {
                                $this->passStatementBlock($catch['statements']);
                            }
                        }
                    }
                    break;

                case 'throw':
                    if (isset($statement['expr'])) {
                        $this->passExpression($statement['expr']);
                    }
                    break;

                case 'fetch':
                    $this->passExpression($statement['expr']);
                    break;

                case 'mcall':
                case 'scall':
                case 'fcall':
                case 'require':
                    $this->passCall($statement['expr']);
                    break;

                case 'unset':
                    if ('array-access' == $statement['expr']['type']) {
                        if ('variable' == $statement['expr']['left']['type']) {
                            $this->increaseMutations($statement['expr']['left']['value']);
                        }
                    } else {
                        if ('list' == $statement['expr']['type']) {
                            if ('array-access' == $statement['expr']['left']['type']) {
                                if ('variable' == $statement['expr']['left']['left']['type']) {
                                    $this->increaseMutations($statement['expr']['left']['left']['value']);
                                }
                            }
                        }
                    }
                    break;

                case 'break':
                case 'continue':
                case 'empty':
                case 'cblock':
                case 'comment':
                    break;

                default:
                    echo 'MutateGathererPassStatement=', $statement['type'], PHP_EOL;
            }
        }
    }
567158
public static function getFromDB( )
    {
        $result = array();
        $objDB = \Database::getInstance( );

        $tables = $objDB->listTables( null, true );
        if( empty($tables) ) {
            return $result;
        }

        foreach( $tables as $table ) {
            $keys = array();
            $fields = $objDB->listFields($table, true);

            foreach( $fields as $field ) {
                $name = $field['name'];
                $field['name'] = '`' . $field['name'] . '`';

                if( in_array(strtolower($field['type']), array('text', 'tinytext', 'mediumtext', 'longtext')) && isset($fields[$name]) ) {
                    $keys[$name] = 'FULLTEXT ';
                }

                //--- Tabellenspalten definieren ---
                if( $field['type'] != 'index' ) {
                    unset($field['index']);

                    // Field type
                    if( isset($field['length']) && ($field['length'] != '') ) {
                        $field['type'] .= '(' . $field['length'] . ((isset($field['precision']) && $field['precision'] != '') ? ',' . $field['precision'] : '') . ')';

                        unset( $field['length'] );
                        unset( $field['precision'] );
                    }

                    // Variant collation
                    if( ($field['collation'] != '') && ($field['collation'] != $GLOBALS['TL_CONFIG']['dbCollation']) ) {
                        $field['collation'] = 'COLLATE ' . $field['collation'];
                    }
                    else {
                        unset( $field['collation'] );
                    }

                    // Default values
                    if( in_array(strtolower($field['type']), array('text', 'tinytext', 'mediumtext', 'longtext', 'blob', 'tinyblob', 'mediumblob', 'longblob')) || stristr($field['extra'], 'auto_increment') || ($field['default'] === null) || (strtolower($field['null']) == 'null') ) {
                        unset( $field['default'] );
                    }
                    // Date/time constants (see #5089)
                    else if( in_array(strtolower($field['default']), array('current_date', 'current_time', 'current_timestamp')) ) {
                        $field['default'] = "default " . $field['default'];
                    }
                    // Everything else
                    else {
                        $field['default'] = "default '" . $field['default'] . "'";
                    }

                    unset( $field['origtype'] );
                    $result[$table]['TABLE_FIELDS'][$name] = trim( implode( ' ', $field ) );
                }

                //--- Index-Einträge ---
                if( isset($field['index']) && !empty($field['index_fields']) ) {
                    $index_fields = '`' . implode( '`, `', $field['index_fields'] ) . '`';
                    $index_fields = str_replace(array('(', ')`'), array('`(', ')'), $index_fields );

                    switch( $field['index'] ) {
                        case 'UNIQUE':  if( $name == 'PRIMARY' ) {
                                            $result[$table]['TABLE_CREATE_DEFINITIONS'][$name] = 'PRIMARY KEY  ('.$index_fields.')';
                                        }
                                        else {
                                            $result[$table]['TABLE_CREATE_DEFINITIONS'][$name] = 'UNIQUE KEY `'.$name.'` ('.$index_fields.')';
                                        }
                                        break;

                        default:        $result[$table]['TABLE_CREATE_DEFINITIONS'][$name] = (isset($keys[$name]) ? $keys[$name] : '') . 'KEY `'.$name.'` ('.$index_fields.')';
                                        break;
                    }
                    unset( $field['index_fields'] );
                    unset( $field['index'] );
                }
            }
        }

        // Table status
        $objStatus = $objDB->execute( 'SHOW TABLE STATUS' );
        while( $zeile = $objStatus->fetchAssoc() ) {
            $result[$zeile['Name']]['TABLE_OPTIONS'] = ' ENGINE=' . $zeile['Engine'] . ' DEFAULT CHARSET=' . substr($zeile['Collation'], 0, strpos($zeile['Collation'],"_"));

            if( $zeile['Auto_increment'] != '' ) {
                $result[$zeile['Name']]['TABLE_OPTIONS'] .= ' AUTO_INCREMENT=' . $zeile['Auto_increment'];
            }
        }

        return $result;
    }
21215
function GetTables()
    {
        $tables = array();
        $sql = new Sql\Builder($this);
        $tbl = $sql->Table('information_schema.tables', array('TABLE_SCHEMA', 'TABLE_NAME'));
        $cond = $sql->Equals($tbl->Field('TABLE_SCHEMA'), $sql->Value($this->dbName));
        $what = $sql->SelectList($tbl->Field('TABLE_NAME'));

        $select = $sql->Select(true, $what, $tbl, $cond);
        $reader = $this->ExecuteQuery((string) $select);
        while ($reader->Read())
        {
            $tables[] = $reader->ByIndex(0);
        }
        return $tables;
    }
1346784
static public function instance($srcPath, $codePool)
    {
        if (!self::$_instance) {
            self::$_instance = new WpLoader($srcPath, $codePool);
        }
        return self::$_instance;
    }
69797
protected function createSessionTable($db,$tableName)
	{
		switch($db->getDriverName())
		{
			case 'mysql':
				$blob='LONGBLOB';
				break;
			case 'pgsql':
				$blob='BYTEA';
				break;
			case 'sqlsrv':
			case 'mssql':
			case 'dblib':
				$blob='VARBINARY(MAX)';
				break;
			default:
				$blob='BLOB';
				break;
		}
		$db->createCommand()->createTable($tableName,array(
			'id'=>'CHAR(32) PRIMARY KEY',
			'expire'=>'integer',
			'data'=>$blob,
		));
	}