Doctrine\DBAL\Exception\ConnectionException {#554 -query: null }
case 1370:
case 1429:
case 2002:
case 2005:
case 2054:
return new ConnectionException($exception, $query);
case 2006:
return new ConnectionLost($exception, $query);
case 1048:
private function handleDriverException(
Driver\Exception $driverException,
?Query $query
): DriverException {
$this->exceptionConverter ??= $this->_driver->getExceptionConverter();
$exception = $this->exceptionConverter->convert($driverException, $query);
if ($exception instanceof ConnectionLost) {
$this->close();
}
}
/** @internal */
final public function convertException(Driver\Exception $e): DriverException
{
return $this->handleDriverException($e, null);
}
/**
* @param array<int, mixed>|array<string, mixed> $params
* @param array<int, int|string|Type|null>|array<string, int|string|Type|null> $types
}
try {
$this->_conn = $this->_driver->connect($this->params);
} catch (Driver\Exception $e) {
throw $this->convertException($e);
}
if ($this->autoCommit === false) {
$this->beginTransaction();
}
}
// If not connected, we need to connect now to determine the platform version.
if ($this->_conn === null) {
try {
$this->connect();
} catch (Exception $originalException) {
if (! isset($this->params['dbname'])) {
throw $originalException;
}
*
* @throws Exception If an invalid platform was specified for this connection.
*/
private function detectDatabasePlatform(): AbstractPlatform
{
$version = $this->getDatabasePlatformVersion();
if ($version !== null) {
assert($this->_driver instanceof VersionAwarePlatformDriver);
return $this->_driver->createDatabasePlatformForVersion($version);
* @throws Exception
*/
public function getDatabasePlatform()
{
if ($this->platform === null) {
$this->platform = $this->detectDatabasePlatform();
$this->platform->setEventManager($this->_eventManager);
$this->platform->setDisableTypeComments($this->_config->getDisableTypeComments());
}
return $this->platform;
}
/** @throws Exception */
private function getSQLForSelect(): string
{
return $this->connection->getDatabasePlatform()
->createSelectSQLBuilder()
->buildSQL(
new SelectQuery(
$this->sqlParts['distinct'],
$this->sqlParts['select'],
case self::UPDATE:
$sql = $this->getSQLForUpdate();
break;
case self::SELECT:
$sql = $this->getSQLForSelect();
break;
}
$this->state = self::STATE_CLEAN;
$this->sql = $sql;
/**
* @return string
*/
public function getSQL()
{
$sql = parent::getSQL();
if ($this->getTitle()) {
$sql = '# ' . $this->title . \PHP_EOL . $sql;
}
* @throws Exception
*/
public function executeQuery(): Result
{
return $this->connection->executeQuery(
$this->getSQL(),
$this->params,
$this->paramTypes,
$this->resultCacheProfile,
);
}