Renames all order tables if they exist.

@param array $stmts Associative array of tables names and lists of SQL statements to execute.
487765
protected function _process( array $stmts )
	{
		$this->_msg( 'Renaming order columns pdate,ddate,dstatus,pstatus', 0 );
		$this->_status( '' );

		foreach( $stmts as $col => $stmt )
		{
			$this->_msg( sprintf( 'Checking columne "%1$s": ', $col ), 1 );

			if( $this->_schema->columnExists( 'mshop_order', $col ) )
			{
				$this->_execute( $stmt );
				$this->_status( 'renamed' );
			} else {
				$this->_status( 'OK' );
			}
		}
	}
123775
protected function cleanDatabase(array $tables)
    {
        DB::statement($this->getForeignKeyCheck(false));
        foreach ($tables as $table) {
            if (Schema::hasTable($table)) {
                DB::table($table)->truncate();
            }
        }
        DB::statement($this->getForeignKeyCheck(true));
    }
1197036
public function prettyPrintFile(array $stmts)
    {
        $p = rtrim($this->prettyPrint($stmts));
        $p = preg_replace('/^\?>\n?/', '', $p, -1, $count);
        $p = preg_replace('/<\?php$/', '', $p);
        if (!$count) {
            $p = sprintf("%s\n\n%s", $this->color('<?php', SyntaxHighlighterConfig::TYPE_OPEN_TAG), $p);
        }
        return $p;
    }
850867
protected function _process( array $stmts )
	{
		$column = 'domain';
		$this->_msg( 'Changing "domain" columns', 0 ); $this->_status( '' );

		foreach( $stmts as $table=>$stmtList )
		{
			$this->_msg( sprintf( 'Checking table "%1$s": ', $table ), 1 );

			if( $this->_schema->tableExists( $table ) === true
				&& $this->_schema->columnExists( $table, $column ) === true
				&& $this->_schema->getColumnDetails( $table, $column )->getDataType() == "varchar"
				&& $this->_schema->getColumnDetails( $table, $column )->getMaxLength() != 32 )
			{
				$this->_executeList( $stmtList );
				$this->_status( 'migrated' );
			}
			else
			{
				$this->_status( 'OK' );
			}
		}
	}
1089789
public function reset_caches($tablenames = null) {
        if (!empty($tablenames)) {
            $dbmetapurged = false;
            foreach ($tablenames as $tablename) {
                if ($this->temptables->is_temptable($tablename)) {
                    $this->get_temp_tables_cache()->delete($tablename);
                } else if ($dbmetapurged === false) {
                    $this->tables = null;
                    $this->get_metacache()->purge();
                    $this->metacache = null;
                    $dbmetapurged = true;
                }
            }
        } else {
            $this->get_temp_tables_cache()->purge();
            $this->tables = null;
            // Purge MUC as well.
            $this->get_metacache()->purge();
            $this->metacache = null;
        }
    }
1266125
public function rename($mainMenuOriginal, $subMenuOriginal, $mainMenuRenamed, $subMenuRenamed)
    {
        $this->renames[] = array($mainMenuOriginal, $subMenuOriginal,
                                 $mainMenuRenamed, $subMenuRenamed);
    }
1027075
protected function _process( array $stmts )
	{
		$this->_msg( 'Changing list ids to NOT NULL', 0 );
		$this->_status('');
		
		foreach( $stmts as $tablename => $stmt )
		{
			$this->_msg(sprintf('Checking table "%1$s": ', $tablename), 1);
			
			if( $this->_schema->tableExists( $tablename ) === true
				&& $this->_schema->getColumnDetails( $tablename, 'id' )->isNullable() === true )
			{
				$this->_execute( $stmt );
				$this->_status( 'migrated' );
			}
			else
			{
				$this->_status( 'OK' );
			}
		}
	}
82056
def rename_tables(db, table_mapping, reverse=False):
    
    from django.db import connection
    if reverse:
        table_mapping = [(dst, src) for src, dst in table_mapping]
    table_names = connection.introspection.table_names()
    for source, destination in table_mapping:
        if source in table_names and destination in table_names:
            print(u"    WARNING: not renaming {0} to {1}, because both tables already exist.".format(source, destination))
        elif source in table_names and destination not in table_names:
            print(u"     - renaming {0} to {1}".format(source, destination))
            db.rename_table(source, destination)
1247220
private function bind($stmt) {

		$meta 	= $stmt -> result_metadata();
		$double = [];
		$vars 	= [];

		if($stmt -> field_count > 0) {

			while($field = $meta -> fetch_field()) {

				$columnname  = $field -> name;
				${$columnname} = null;
				
				if(true === array_key_exists($columnname, $vars)) {
					$double[] = $columnname;
				}
				else {
					$vars[$columnname] = &${$columnname};
				}
			}
		}

		if(count($double) > 0) {
			return trigger_error(sprintf('Column %s in field list is ambiguous', implode(', ', array_unique($double))));
		}

		call_user_func_array([$stmt, 'bind_result'], $vars);

		return $vars;
	}
1250356
protected function _process( array $stmts )
	{
		$this->_msg( 'Migrating "Complete" to "BasketLimits" plugin', 0 ); $this->_status( '' );

		if( $this->_schema->columnExists( 'mshop_plugin', 'config' ) === true
			&& $this->_schema->columnExists( 'mshop_plugin', 'provider' ) === true
		) {
			foreach( $stmts as $key => $list )
			{
				$this->_msg( sprintf( 'Migrating "%1$s"', $key ), 1 );

				if( $this->_getValue( $list['select'], 'cnt' ) > 0 )
				{
					$this->_execute( $list['update'] );
					$this->_status( 'migrated' );
				}
				else
				{
					$this->_status( 'OK' );
				}
			}
		}
	}
1042754
public function dontRequireTable($table)
    {
        if (!isset($this->tableList[strtolower($table)])) {
            return;
        }
        $prefix = "_obsolete_{$table}";
        $suffix = '';
        $renameTo = $prefix . $suffix;
        while (isset($this->tableList[strtolower($renameTo)])) {
            $suffix = $suffix
                    ? ((int)$suffix + 1)
                    : 2;
            $renameTo = $prefix . $suffix;
        }
        $renameFrom = $this->tableList[strtolower($table)];
        $this->renameTable($renameFrom, $renameTo);
        $this->alterationMessage("Table $table: renamed to $renameTo", "obsolete");
    }
1041651
protected function _process( array $stmts )
	{
		$this->_msg( 'Migrating order flags to order status list', 0 ); $this->_status( '' );
		$table = 'mshop_order';

		if( $this->_schema->tableExists( $table ) === true )
		{
			$this->_msg( 'Deleting order index with flag colum', 1 );

			if( $this->_schema->indexExists( $table, 'idx_msord_sid_pstat_dstat_flag' ) === true )
			{
				$this->_execute( $stmts['index'] );
				$this->_status( 'dropped' );
			}
			else
			{
				$this->_status( 'OK' );
			}


			$this->_msg( 'Migrating order flag colum', 1 );

			if( $this->_schema->columnExists( $table, 'flag' ) === true )
			{
				$cntRows = 0;
				$mapping = array();

				for( $i = 1; $i < 16; $i++ ) {
					$mapping[ 0x1 << $i ] = 0x1 << $i;
				}

				$mapping[1] = 'stock-update';

				foreach( $mapping as $key => $value )
				{
					$stmt = $this->_conn->create( $stmts['migrate'] );
					$stmt->bind( 1, $value );
					$stmt->bind( 2, $key );
					$stmt->bind( 3, $value );

					$result = $stmt->execute();
					$cntRows += $result->affectedRows();
					$result->finish();
				}

				$this->_execute( $stmts['column'] );

				if( $cntRows > 0 ) {
					$this->_status( sprintf( 'migrated (%1$d)', $cntRows ) );
				} else {
					$this->_status( 'OK' );
				}
			}
			else
			{
				$this->_status( 'OK' );
			}
		}
		else
		{
			$this->_status( 'OK' );
		}

	}
224521
private void _buildOrderClause(
                    final List<Order> orders,
                    final StringBuilder stmt
                    )
    {
        int  n_orders = (orders == null ? 0 : orders.size());
        if (n_orders == 0) {
            return;
        }

        stmt.append( _ORDER_BY_ );
        for (int  i = 0; i < n_orders; i++) {
            if (i > 0) {
                stmt.append( "," );
            }

            final Order  order = orders.get( i );
            _buildProperty( order.getProperty(), stmt );
            //throws SearchException

            if (order.isDescending()) {
                stmt.append( _DESC_ );
            }
        }
    }
330145
protected function _process( array $stmts )
	{
		$this->_msg( 'Changing PRIMARY KEYS for locale', 0 ); $this->_status( '' );

		$search = '
			SELECT COUNT(INDEX_NAME) "counter" FROM
			INFORMATION_SCHEMA.STATISTICS WHERE TABLE_SCHEMA = DATABASE()
			AND TABLE_NAME = \'%1$s\' AND INDEX_NAME = \'PRIMARY\'
			AND COLUMN_NAME IN(\'id\', \'siteid\')
		';

		foreach( $stmts as $table => $stmt )
		{
			$this->_msg( sprintf( 'Checking table "%1$s" for PRIMARY": ', $table ), 1 );
			$counter = $this->_getValue( sprintf( $search, $table ), 'counter' );

			if( $counter == 2 )
			{
				$this->_execute( $stmt );
				$this->_status( 'changed' );
			}
			else
			{
				$this->_status( 'OK' );
			}
		}
	}
1145082
public static function rename($table, $new_name)
	{
		$table = new Table($table);

		// To indicate that the table needs to be renamed, we will run the
		// "rename" command on the table instance and pass the instance to
		// the execute method as calling a Closure isn't needed.
		$table->rename($new_name);

		return static::execute($table);
	}
475305
public function setTables(array $tables)
    {
        $this->tables = array();

        foreach ($tables as $table) {
            $this->addTable($table);
        }
    }
186306
protected function renameStubs()
    {
        foreach ($this->stubsToRename() as $stub) {
            (new Filesystem)->move($stub, str_replace('.stub', '.php', $stub));
        }
    }