-
Notifications
You must be signed in to change notification settings - Fork 7.9k
PDO_Firebird: Add connection level SESSION_TIMEZONE attribute #15480
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
Changes from 3 commits
06fd881
47c92e4
9b621c7
83f3535
adf9826
cc0073f
1d290b0
a9eeb2e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
--TEST-- | ||
PDO_Firebird: Firebird 4.0 set session time zone | ||
--EXTENSIONS-- | ||
pdo_firebird | ||
--SKIPIF-- | ||
<?php require('skipif.inc'); | ||
if (Pdo\Firebird::getApiVersion() < 40) { | ||
die('skip: Firebird API version must be greater than or equal to 40'); | ||
} | ||
require 'testdb.inc'; | ||
checkMinServerVersion('4.0.0'); | ||
?> | ||
--XLEAK-- | ||
A bug in firebird causes a memory leak when calling `isc_attach_database()`. | ||
See https://github.com/FirebirdSQL/firebird/issues/7849 | ||
--FILE-- | ||
<?php | ||
|
||
$sql = <<<'SQL' | ||
SELECT | ||
rdb$get_context('SYSTEM', 'SESSION_TIMEZONE') as tz, | ||
trim(replace(current_timestamp, localtimestamp, '')) as tz1, | ||
trim(replace(current_time, localtime, '')) as tz2 | ||
FROM rdb$database | ||
SQL; | ||
|
||
$dbh = connectToDb([ | ||
Pdo\Firebird::SESSION_TIMEZONE => 'Europe/Rome', | ||
]); | ||
|
||
$stmt = $dbh->prepare($sql); | ||
$stmt->execute(); | ||
$data = $stmt->fetch(\PDO::FETCH_ASSOC); | ||
$stmt->closeCursor(); | ||
|
||
var_dump($data); | ||
echo "\ndone\n"; | ||
?> | ||
--EXPECT-- | ||
array(3) { | ||
["TZ"]=> | ||
string(11) "Europe/Rome" | ||
["TZ1"]=> | ||
string(11) "Europe/Rome" | ||
["TZ2"]=> | ||
string(11) "Europe/Rome" | ||
} | ||
|
||
done |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,15 +14,25 @@ define('PDO_FIREBIRD_TEST_DSN', getenv('PDO_FIREBIRD_TEST_DSN') ?: ''); | |
|
||
if(!PDO_FIREBIRD_TEST_DSN) | ||
{ | ||
die('Error: PDO_FIREBIRD_TEST_DSN must be set'); | ||
die('Error: PDO_FIREBIRD_TEST_DSN must be set'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd stick with 4 spaces as indentation in PHP files, but I don't think we have any CS in this regard. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK |
||
} | ||
|
||
function getDbConnection($class = PDO::class): PDO { | ||
return new $class(PDO_FIREBIRD_TEST_DSN, PDO_FIREBIRD_TEST_USER, PDO_FIREBIRD_TEST_PASS); | ||
return new $class(PDO_FIREBIRD_TEST_DSN, PDO_FIREBIRD_TEST_USER, PDO_FIREBIRD_TEST_PASS); | ||
} | ||
|
||
function connectToDb(): Pdo\Firebird { | ||
return Pdo\Firebird::connect(PDO_FIREBIRD_TEST_DSN, PDO_FIREBIRD_TEST_USER, PDO_FIREBIRD_TEST_PASS); | ||
function connectToDb(array $params = []): Pdo\Firebird { | ||
return Pdo\Firebird::connect(PDO_FIREBIRD_TEST_DSN, PDO_FIREBIRD_TEST_USER, PDO_FIREBIRD_TEST_PASS, $params); | ||
} | ||
|
||
function checkMinServerVersion(string $version): void | ||
{ | ||
$dbh = connectToDb(); | ||
$stmt = $dbh->query("SELECT RDB\$GET_CONTEXT('SYSTEM', 'ENGINE_VERSION') AS VERSION FROM RDB\$DATABASE"); | ||
$data = $stmt->fetch(\PDO::FETCH_ASSOC); | ||
if (!$data || !array_key_exists('VERSION', $data) || version_compare($data['VERSION'], $version) < 0) { | ||
die("skip Firebird Server version must be greater than or equal to $version"); | ||
} | ||
} | ||
|
||
?> |
Uh oh!
There was an error while loading. Please reload this page.