Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Named timezones doc #232

Merged
merged 2 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading