For a while, we were scratching our heads over why persistent connections were not being created when using PDO_OCI, even though we were explicitly calling PDO::setAttribute() to set PDO::ATTR_PERSISTENT.
My colleague Brian DeShong further explains the issue on his blog: http://www.deshong.net/?p=61 "You must set PDO::ATTR_PERSISTENT => true in the array of options you pass to the PDO constructor! If you call $pdo->setAttribute(PDO::ATTR_PERSISTENT, true) after the instantiation of the object, you won’t be using persistent connections." He goes on to say: "It’d be nice if PDO::setAttribute() raised a warning if you try to set PDO::ATTR_PERSISTENT, by the way." I'm submitting the attached patch to do just that. :-) -- Ben Ramsey http://benramsey.com/
Index: ext/pdo/pdo_dbh.c =================================================================== RCS file: /repository/php-src/ext/pdo/pdo_dbh.c,v retrieving revision 1.82.2.31.2.15 diff -u -r1.82.2.31.2.15 pdo_dbh.c --- ext/pdo/pdo_dbh.c 16 Jul 2007 18:00:18 -0000 1.82.2.31.2.15 +++ ext/pdo/pdo_dbh.c 26 Oct 2007 17:26:57 -0000 @@ -823,6 +823,18 @@ PDO_CONSTRUCT_CHECK; + switch (attr) { + case PDO_ATTR_PERSISTENT: + pdo_raise_impl_error(dbh, NULL, "HY000", + "PDO::ATTR_PERSISTENT cannot be set with PDO::setAttribute(); " + "it must be passed as a driver option to the PDO constructor" TSRMLS_CC); + PDO_HANDLE_DBH_ERR(); + return FAILURE; + + default: + ; + } + if (pdo_dbh_attribute_set(dbh, attr, value TSRMLS_CC) != FAILURE) { RETURN_TRUE; }
-- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php