Change critical PRIMARY KEY-constellation in locale tables.

@param array $stmts List of SQL statements to execute for adding columns
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' );
			}
		}
	}
490149
public function setLocalColumnNames(array $localColumnNames)
    {
        $this->localColumnNames = array();

        foreach ($localColumnNames as $localColumnName) {
            $this->addLocalColumnName($localColumnName);
        }
    }
289588
public function changePrimaryKey($newPrimary)
    {
        if (is_array($newPrimary))
        {
            $primaryKeyString = "(" . implode(",", $key) . ")";
        }
        else
        {
            $primaryKeyString = "(`" . $newPrimary . "`)";
        }
        
        $query = 
            "ALTER TABLE `" . $this->m_name . "` " .
            "DROP PRIMARY KEY, ADD PRIMARY KEY " . $primaryKeyString;
        
        $result = $this->m_mysqliConn->query($query);
        return $result;
    }
4543
public function setMessages(array $translations) {
		foreach ($translations as $key => $message) {
			if($message) {
				$this->msg[$key] = $message;
			}
		}
	}
808800
protected function _process( $stmt )
	{
		$table = 'madmin_log';

		$this->_msg( 'Changing site ID to NULL in madmin_log', 0 );
		$this->_status('');

		$this->_msg(sprintf('Changing table "%1$s": ', $table), 1);

		if( $this->_schema->tableExists($table) &&
			!$this->_schema->getColumnDetails( $table, 'siteid' )->isNullable() )
		{
			$this->_execute( $stmt );
			$this->_status( 'done' );
		} else {
			$this->_status( 'OK' );
		}

	}
325272
protected function _process( array $stmts )
	{
		$table = "madmin_job";
		$this->_msg( sprintf( 'Converting "%1$s" to InnoDB".', $table ), 0 );

		$stmt = $this->_conn->create( $stmts['check'] );
		$stmt->bind( 1, $this->_schema->getDBName() );
		$stmt->bind( 2, $table );
		$result = $stmt->execute();
		$dbname = $result->fetch();
		$result->finish();

		if( $this->_schema->tableExists( $table ) === true
			&& $dbname['ENGINE'] === 'MyISAM' )
		{
			$this->_execute( $stmts['convert'] );
			$this->_status( 'converted' );
		}
		else
		{
			$this->_status( 'OK' );
		}
	}
684667
public function changePrimaryKey($columns)
    {
        $this->actions->addAction(new ChangePrimaryKey($this->table, $columns));

        return $this;
    }
960888
public function execute(array $params, $stmt = null)
    {
        try {
            if (!is_null($stmt)) {
                $this->stmt = $stmt->execute($params);
            } else {
                if (!$this->stmt) {
                    throw new \Exception("Prepared stetement not found.");
                }
                $this->stmt->execute($params);
            }
            return $this;
        } catch (\PDOException $e) {
            die("Error: " . $e->getMessage());
        } catch (\Exception $e) {
            die("Error: " . $e->getMessage());
        }
    }
1285604
public function setSqlParameters(array $params)
    {
        $this->params = $params;

        $this->stmt = null;
        $this->rowCount = null;
    }
1140708
public function setAliases(array $aliases)
    {
        $this->aliases = [];

        foreach ($aliases as $alias => $countryCode) {
            $this->aliases[strtoupper($alias)] = strtoupper($countryCode);
        }
    }
1323435
public function addStmt($stmt)
    {
        if (method_exists($stmt, 'isMixinCode')) {
            $name = $stmt->getName();
        } else {
            $stmt = $this->normalizeNode($stmt);
            if ($stmt instanceof Stmt\ClassConst) {
                $name = $stmt->consts[0]->name;
            } elseif ($stmt instanceof Stmt\Property) {
                $name = $stmt->props[0]->name;
            } elseif (property_exists($stmt, 'name')) {
                $name = $stmt->name;
            }
        }
        $type = $stmt->getType();
        switch ($type) {
            case 'Stmt_TraitUse':
                $this->uses[] = $stmt;
                break;
            case 'Stmt_ClassConst':
                $this->constants[$name] = $stmt;
                break;
            case 'Stmt_Property':
                $stmt = new PropertyCode($stmt);
                // no break
            case 'PropertyCode':
                $this->properties[$name] = $stmt;
                break;
            case 'Stmt_ClassMethod':
                $stmt = new MethodCode($stmt);
                // no break
            case 'MethodCode':
                $name = strtolower($name);
                $this->methods[$name] = $stmt;
                break;
        }
        $this->stmts[] = $stmt;
        return $this;
    }
1200680
public function setAddedFks(array $addedFks)
    {
        $this->addedFks = [];
        foreach ($addedFks as $addedFk) {
            $this->addAddedFk($addedFk->getName(), $addedFk);
        }
    }
1009996
public function addStmt($stmt)
    {
        if (method_exists($stmt, 'isMixinCode')) {
            $name = strval($stmt->getName());
        } else {
            $stmt = self::getStmtNode($stmt);
            $name = isset($stmt->name) ? strval($stmt->name) : null;
        }
        $type = $stmt->getType();
        switch ($type) {
            case 'Stmt_Namespace':
                $this->namespaces[$name] = $this->offset;
                break;
            case 'Stmt_Class':
            case 'Stmt_Interface':
            case 'Stmt_Trait':
                $stmt = new Code\ClassCode($stmt);
                // no break
            case 'ClassCode':
                $this->classes[$name] = $this->offset;
                break;
            case 'Stmt_Function':
                $stmt = new Code\FunctionCode($stmt);
                // no break
            case 'FunctionCode':
                $name = strtolower($name);
                $this->functions[$name] = $this->offset;
                break;
        }
        $this->stmts[$this->offset++] = $stmt;
        return $this;
    }
1144038
protected function setStmtError($stmt = null)
    {
        if ($stmt) {
            $this->setErrorCode(db2_stmt_error($stmt));
            $this->setErrorMsg(db2_stmt_errormsg($stmt));
        } else {
            $this->setErrorCode(db2_stmt_error());
            $this->setErrorMsg(db2_stmt_errormsg());
        }        
    }
124944
function save($table, $data, $primary_key, $stmt_key = null)
    {
        // Update if primary key exists in data set or insert new row
        if (!empty($data[$primary_key])) {
            return $this->update($table, $data, $primary_key . " = ?", $data[$primary_key], $stmt_key);
        } else {
            return $this->insert($table, $data, $stmt_key);
        }
    }
1185986
protected function process( array $stmts )
	{
		$this->msg( 'Removing locale constraints from customer tables', 0 );
		$this->status( '' );

		$schema = $this->getSchema( 'db-customer' );

		foreach( $stmts as $table => $list )
		{
			if( $schema->tableExists( $table ) === true )
			{
				foreach( $list as $constraint => $stmt )
				{
					$this->msg( sprintf( 'Removing "%1$s" from "%2$s"', $constraint, $table ), 1 );

					if( $schema->constraintExists( $table, $constraint ) !== false )
					{
						$this->execute( $stmt, 'db-customer' );
						$this->status( 'done' );
					} else {
						$this->status( 'OK' );
					}
				}
			}
		}
	}
441647
protected function _process( array $stmts )
	{
		$table = 'mshop_plugin';
		$constraint = 'fk_msplu_typeid';

		$this->_msg( 'Adding constraint for table mshop_plugin', 0 ); $this->_status( '' );

		$this->_msg( sprintf( 'Checking constraint "%1$s": ', $constraint ), 1 );

		if( $this->_schema->tableExists( $table ) === true
			&& $this->_schema->columnExists( $table, 'typeid' )
			&& $this->_schema->constraintExists( $table, $constraint ) === false )
		{
			$this->_execute( $stmts[ $constraint ] );
			$this->_status( 'added' );
		}
		else
		{
			$this->_status( 'OK' );
		}
	}