Req #71130 [NEW]: Allow PDO to lazy-connect
| From: | tom at r dot je | Date: | Tue, 15 Dec 2015 21:26:13 +0000 |
| Subject: | Req #71130 [NEW]: Allow PDO to lazy-connect | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-197916@lists.php.net to get a copy of this message | ||
From: tom at r dot je
Operating system: Any
PHP version: 7.0.0
Package: PDO related
Bug Type: Feature/Change Request
Bug description:Allow PDO to lazy-connect
Description:
------------
Currently PDO connects when an instance is created
new PDO(....); will
connect to the database at the point the PDO object is created.
For performance reasons sometimes this is not required and due to the
way a lot of frameworks work, will mean connecting even if a query is
never made.
To overcome this, PDO is often wrapped in a class which connects at the
point a query (or prepare, or other database requiring function is
called. See
http://stackoverflow.com/questions/23595609/is-this-how-lazy-connecting-of-a-database-connection-is-supposed-to-be
and
http://stackoverflow.com/questions/5484790/auto-connecting-to-pdo-only-if-needed
It would be better if PDO supported lazy connection as an option when
the object is instantiated, for example:
<?php
$dbh = new PDO($dsn, $user, $password, PDO::LAZY_CONNECT);
?>
Which would only connect to the database server when query(), prepare()
or other similar functions are called.
--
Edit bug report at https://bugs.php.net/bug.php?id=71130&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=71130&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=71130&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=71130&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=71130&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=71130&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=71130&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=71130&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=71130&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=71130&r=support
Expected behavior: https://bugs.php.net/fix.php?id=71130&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=71130&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=71130&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=71130&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=71130&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=71130&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=71130&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=71130&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=71130&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=71130&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=71130&r=mysqlcfg