Converts MyISAM table to InnoDB.

@param array $stmts List of SQL statements to execute for changing table
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' );
		}
	}
945280
public function adapt(PDOException $e, $stmt = null, array $params = null) {
		if ($e instanceof DatabaseException) {
			return $e;
		}

		$dbe = new DatabaseException($e, $stmt, $params);

		$code = $e->getCode();
		switch ($code) {
			case '42501':
			$dbe->isAuthorizationError(true);
			break;

			case '42710':
			$dbe->userAlreadyExists(true);
			break;

			case '42P04':
			$dbe->databaseAlreadyExists(true);
			break;

			case '42P01':
			$dbe->tableDoesNotExist(true);
			break;
		}

		return $dbe;
	}
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;
    }
495434
public function populateCheckers(array $stmts)
    {
        $leftover_stmts = [];

        foreach ($stmts as $stmt) {
            if ($stmt instanceof PhpParser\Node\Stmt\ClassLike) {
                $this->populateClassLikeAnalyzers($stmt);
            } elseif ($stmt instanceof PhpParser\Node\Stmt\Namespace_) {
                $namespace_name = $stmt->name ? implode('\\', $stmt->name->parts) : '';

                $namespace_analyzer = new NamespaceAnalyzer($stmt, $this);
                $namespace_analyzer->collectAnalyzableInformation();

                $this->namespace_aliased_classes[$namespace_name] = $namespace_analyzer->getAliases()->uses;
                $this->namespace_aliased_classes_flipped[$namespace_name] =
                    $namespace_analyzer->getAliasedClassesFlipped();
            } elseif ($stmt instanceof PhpParser\Node\Stmt\Use_) {
                $this->visitUse($stmt);
            } elseif ($stmt instanceof PhpParser\Node\Stmt\GroupUse) {
                $this->visitGroupUse($stmt);
            } else {
                if ($stmt instanceof PhpParser\Node\Stmt\If_) {
                    foreach ($stmt->stmts as $if_stmt) {
                        if ($if_stmt instanceof PhpParser\Node\Stmt\ClassLike) {
                            $this->populateClassLikeAnalyzers($if_stmt);
                        }
                    }
                }

                $leftover_stmts[] = $stmt;
            }
        }

        return $leftover_stmts;
    }
808859
private function doBind(Statement $stmt)
    {
        foreach ($this->boundValues as $key => $value) {
            $stmt->bindValue($key, $value, $this->boundValuesType[$key]);
        }
        foreach ($this->boundParameters as $key => &$value) {
            $stmt->bindParam($key, $value, $this->boundParametersType[$key]);
        }
    }
1099245
private function bindParam($stmt)
    {
        // Bind parameters
        for ($i = 1; $i <= count($this->bindings); $i++) {
            $stmt->bindParam($i, $this->bindings[$i - 1]);
        }
    }
1169988
private function loadArrayFromStatement($assoc, $stmt)
    {
        $rsm    = $this->currentPersisterContext->rsm;
        $hints  = array(UnitOfWork::HINT_DEFEREAGERLOAD => true);

        if (isset($assoc['indexBy'])) {
            $rsm = clone ($this->currentPersisterContext->rsm); // this is necessary because the "default rsm" should be changed.
            $rsm->addIndexBy('r', $assoc['indexBy']);
        }

        return $this->em->newHydrator(Query::HYDRATE_OBJECT)->hydrateAll($stmt, $rsm, $hints);
    }
1136921
public static function find($stmt)
    {
         try {
            $result = $stmt->fetch(PDO::FETCH_ASSOC);
            if(! $result) {
                throw new Exception(" Record not found.");
            }

            $object = new static;
            $object->id = $result['id'];
            $object->result = json_encode($result);

            return $object;
        }
        catch(PDOException $pe) {
            return $pe->getMessage();
        }
        catch(Exception $e) {
            return $e->getMessage();
        }
    }
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' );
		}
	}
930798
protected function getContentDbFieldsStmt(array $fields)
    {
        $query = $this->databaseHandler->createSelectQuery();
        $query->select($fields)
            ->from($this->databaseHandler->quoteTable(self::CONTENTOBJECT_TABLE))
            ->where($query->expr->eq('status', ContentInfo::STATUS_PUBLISHED));
        $stmt = $query->prepare();
        $stmt->execute();

        return $stmt;
    }
1147111
protected function _process( $stmt )
	{
		$msg = 'Changing code from "product" to "default" in "mshop_product_type"';
		$this->_msg($msg, 0);

		if ($this->_schema->tableExists('mshop_product_type') )
		{
			$result = $this->_conn->create( $stmt )->execute();
			$cntRows = $result->affectedRows();
			$result->finish();

			if ( $cntRows ) {
				$this->_status( sprintf( 'migrated (%1$d)', $cntRows ) );
			} else {
				$this->_status( 'OK' );
			}
		}
		else
		{
			$this->_status('OK');
		}
	}
124725
private function executeParallel($stmt, array $values = null): PromiseInterface
    {
        if (is_string($stmt)) {
            $stmt = $this->emulatePrepare((string) $stmt, $values);
        } else {
            if (!$stmt instanceof Statement) {
                throw new \InvalidArgumentException(sprintf('Expected %s object, got %s', Statement::class, get_class($stmt)));
            }
            if (!$stmt instanceof EmulatedStatement) {
                $stmt = $this->emulatePrepare((string) $stmt, $values ?? $stmt->getValues());
            } elseif (null !== $values) {
                $stmt = $stmt->withValues($values);
            }
        }
        try {
            // Clone connection (Mysqli Asynchronous queries require a different connection to work properly)
            $credentials = $this->getCredentials();
            $cnx         = self::createLink($credentials);
            if ($this->hasOption('charset')) {
                $cnx->set_charset($this->getOption('charset'));
            }
        } catch (mysqli_sql_exception $e) {
            throw new AccessDeniedException($e->getMessage(), (int) $e->getCode(), $e);
        }

        $stmt->bind();
        $promise = MysqliAsync::query($stmt->getRunnableQuery(), $cnx)->then(function ($result) use ($cnx, $stmt) {
            if (!$result instanceof mysqli_result) {
                $result = null;
            }
            return new Result($cnx, $result);
        });

        return $promise;
    }
1180683
protected function process( array $stmts )
	{
		$this->msg( 'Adding "vatid" column to fe_users tables', 0 ); $this->status( '' );

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

			if( $this->schema->tableExists( $table ) === true
				&& $this->schema->columnExists( $table, 'vatid' ) === false )
			{
				$this->execute( $stmt );
				$this->status( 'added' );
			} else {
				$this->status( 'OK' );
			}
		}
	}
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' );
			}
		}
	}
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' );
		}

	}
273536
public function uninstallDatabaseFor(array $metadatas)
    {
        if (count($metadatas) > 0) {
            $em = $this->getEntityManager();
            $conn = $em->getConnection();
            $sm = $conn->getSchemaManager();
            $cmf = $em->getMetadataFactory();
            $tool = new \Doctrine\ORM\Tools\SchemaTool($em);

            $newSchema = $tool->getSchemaFromMetadata($metadatas);

            // We'll let Doctrine resolve the correct drop order for the tables
            // because of which we use the schema migration method to drop the
            // tables. By letting Doctrine resolve the drop order we avoid
            // DB server constraint violation errors (e.g. in MySQL).
            $fromSchema = $sm->createSchema();
            $toSchema = clone $fromSchema;
            foreach ($newSchema->getTables() as $newTable) {
                if ($toSchema->hasTable($newTable->getName())) {
                    $toSchema->dropTable($newTable->getName());
                }
            }
            $sqls = $fromSchema->getMigrateToSql($toSchema, $conn->getDatabasePlatform());

            if (count($sqls) > 0) {
                foreach ($sqls as $sql) {
                    $conn->executeQuery($sql);
                }

                return true;
            }
        }

        return false;
    }
550997
protected function _process( array $stmts )
	{
		$this->_msg( 'Renaming service configuration', 0 );

		if( $this->_schema->tableExists( 'mshop_service' )
			&& $this->_schema->columnExists( 'mshop_service', 'config' ) === true
		) {
			$cntRows = 0;

			foreach( $stmts as $stmt )
			{
				$result = $this->_conn->create( $stmt )->execute();
				$cntRows += $result->affectedRows();
				$result->finish();
			}

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