Skip to content

Commit

Permalink
Merge pull request #232 from nextras/named-timezones-doc
Browse files Browse the repository at this point in the history
Named timezones doc
  • Loading branch information
hrach committed Mar 12, 2024
2 parents 94b3a6e + 647db40 commit 326a56f
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Bridges/NetteTracy/BluescreenQueryPanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ public static function renderBluescreenPanel(?\Throwable $exception): ?array

return [
'tab' => 'SQL',
'panel' => '<pre class="sql">' . SqlHighlighter::highlight($query) . "</pre>",
'panel' => '<pre class="sql">' . SqlHighlighter::highlight($query) . '</pre>' .
"<p>Error code: {$exception->getErrorCode()}<br>SQL STATE: {$exception->getErrorSqlState()}</p>",
];
}
}
27 changes: 27 additions & 0 deletions src/Drivers/Exception/UnknownMysqlTimezone.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php declare(strict_types = 1);

namespace Nextras\Dbal\Drivers\Exception;


use Exception;


class UnknownMysqlTimezone extends QueryException
{
public function __construct(
string $message,
int $errorCode = 0,
string $errorSqlState = '',
Exception $previousException = null,
?string $sqlQuery = null,
)
{
parent::__construct(
$message . "\nSee how to solve the issue: https://nextras.org/dbal/docs/main/timezones-mysql-support",
$errorCode,
$errorSqlState,
$previousException,
$sqlQuery,
);
}
}
3 changes: 3 additions & 0 deletions src/Drivers/Mysqli/MysqliDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Nextras\Dbal\Drivers\Exception\NotNullConstraintViolationException;
use Nextras\Dbal\Drivers\Exception\QueryException;
use Nextras\Dbal\Drivers\Exception\UniqueConstraintViolationException;
use Nextras\Dbal\Drivers\Exception\UnknownMysqlTimezone;
use Nextras\Dbal\Drivers\IDriver;
use Nextras\Dbal\Exception\InvalidStateException;
use Nextras\Dbal\Exception\NotSupportedException;
Expand Down Expand Up @@ -368,6 +369,8 @@ protected function createException(string $error, int $errorNo, string $sqlState
return new ConnectionException($error, $errorNo, $sqlState);
} elseif (in_array($errorNo, [1048, 1121, 1138, 1171, 1252, 1263, 1566], true)) {
return new NotNullConstraintViolationException($error, $errorNo, $sqlState, null, $query);
} elseif ($errorNo === 1298) {
return new UnknownMysqlTimezone($error, $errorNo, $sqlState, null, $query);
} elseif ($query !== null) {
return new QueryException($error, $errorNo, $sqlState, null, $query);
} else {
Expand Down
3 changes: 3 additions & 0 deletions src/Drivers/PdoMysql/PdoMysqlDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Nextras\Dbal\Drivers\Exception\NotNullConstraintViolationException;
use Nextras\Dbal\Drivers\Exception\QueryException;
use Nextras\Dbal\Drivers\Exception\UniqueConstraintViolationException;
use Nextras\Dbal\Drivers\Exception\UnknownMysqlTimezone;
use Nextras\Dbal\Drivers\IDriver;
use Nextras\Dbal\Drivers\Pdo\PdoDriver;
use Nextras\Dbal\Exception\InvalidArgumentException;
Expand Down Expand Up @@ -153,6 +154,8 @@ protected function createException(string $error, int $errorNo, string $sqlState
return new ConnectionException($error, $errorNo, $sqlState);
} elseif (in_array($errorNo, [1048, 1121, 1138, 1171, 1252, 1263, 1566], true)) {
return new NotNullConstraintViolationException($error, $errorNo, $sqlState, null, $query);
} elseif ($errorNo === 1298) {
return new UnknownMysqlTimezone($error, $errorNo, $sqlState, null, $query);
} elseif ($query !== null) {
return new QueryException($error, $errorNo, $sqlState, null, $query);
} else {
Expand Down

0 comments on commit 326a56f

Please sign in to comment.