-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Pdo subclassing #11740
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
Pdo subclassing #11740
Changes from all commits
551ab85
6fb4c7f
770658e
ecb641a
f79a562
28e2a5c
4134358
5df9630
a3f690a
af73177
2e78541
fbe86b7
497e192
6d137ff
c579fd8
b5c92d3
8a5bcdd
da341c2
f184b17
d20705f
4fc8305
0ebe730
0ddc2d2
b820c99
0a785cc
e0652bf
82b7a83
157cd85
abcd936
c6ea6f5
e18dcea
4989bbc
b009e04
ada37de
fbfc99b
b6aa681
4313d96
c82219a
344935f
14f2db0
716e1d0
1b5c4c4
9207ade
d2db467
95a2226
46dd89a
fd3a4ae
f21948e
67e0deb
67fa7b1
c0ff7ea
6d42f7e
e7a1137
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -388,6 +388,13 @@ class PDO | |||||||
|
||||||||
public function __construct(string $dsn, ?string $username = null, #[\SensitiveParameter] ?string $password = null, ?array $options = null) {} | ||||||||
|
||||||||
public static function connect( | ||||||||
string $dsn, | ||||||||
?string $username = null, | ||||||||
?string $password = null, | ||||||||
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. Might fix some of the tests
Suggested change
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. Do you mean php-src/ext/pdo/tests/sensitive_parameter.phpt? If so, I think that might not be my fault, as I haven't touched that test. But yes, that probably should be there, and a test for it. |
||||||||
?array $options = null | ||||||||
): PDO|PDOSqlite {} | ||||||||
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.
|
||||||||
|
||||||||
/** @tentative-return-type */ | ||||||||
public function beginTransaction(): bool {} | ||||||||
|
||||||||
|
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,9 @@ | ||
<?php | ||
|
||
/** @generate-class-entries */ | ||
|
||
/** @not-serializable */ | ||
class PdoDblib extends PDO | ||
{ | ||
|
||
} |
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,24 @@ | ||
<?php | ||
|
||
function getDsnUserAndPassword() | ||
{ | ||
|
||
if (false !== getenv('PDO_DBLIB_TEST_DSN')) { | ||
$dsn = getenv('PDO_DBLIB_TEST_DSN'); | ||
} else { | ||
$dsn = 'dblib:host=localhost;dbname=test'; | ||
} | ||
|
||
if (false !== getenv('PDO_DBLIB_TEST_USER')) { | ||
$user = getenv('PDO_DBLIB_TEST_USER'); | ||
} else { | ||
$user = 'php'; | ||
} | ||
|
||
if (false !== getenv('PDO_DBLIB_TEST_PASS')) { | ||
$pass = getenv('PDO_DBLIB_TEST_PASS'); | ||
} else { | ||
$pass = 'password'; | ||
} | ||
return [$dsn, $user, $pass]; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
--TEST-- | ||
PdoDblib basic | ||
--EXTENSIONS-- | ||
pdo | ||
--FILE-- | ||
<?php | ||
|
||
require_once __DIR__ . "/../config_functions.inc"; | ||
|
||
if (class_exists(PdoDblib::class) === false) { | ||
echo "PdoDblib class does not exist.\n"; | ||
exit(-1); | ||
} | ||
echo "PdoDblib class exists.\n"; | ||
|
||
|
||
[$dsn, $user, $pass] = getDsnUserAndPassword(); | ||
|
||
$db = new PdoDblib($dsn, $user, $pass); | ||
|
||
$db->query('drop table if exists #foobar;'); | ||
|
||
$db->query("create table #foobar(name varchar(32)); "); | ||
$db->query("insert into #foobar values('PHP');"); | ||
$db->query("insert into #foobar values('PHP6');"); | ||
|
||
foreach ($db->query('SELECT name FROM #foobar') as $row) { | ||
var_dump($row); | ||
} | ||
|
||
$db->query('drop table #foobar;'); | ||
|
||
echo "Fin."; | ||
?> | ||
--EXPECT-- | ||
PdoDblib class exists. | ||
array(2) { | ||
["name"]=> | ||
string(3) "PHP" | ||
[0]=> | ||
string(3) "PHP" | ||
} | ||
array(2) { | ||
["name"]=> | ||
string(4) "PHP6" | ||
[0]=> | ||
string(4) "PHP6" | ||
} | ||
Fin. |
Uh oh!
There was an error while loading. Please reload this page.