Re: PDO custom class for statement
| From: | Ludovic Levesque | Date: | Thu, 04 May 2006 11:59:05 +0000 |
| Subject: | Re: PDO custom class for statement | ||
| References: | 1 2 | Groups: | php.pecl.dev |
| Request: | Send a blank email to pecl-dev+get-3749@lists.php.net to get a copy of this message | ||
Ok thanks for the rapid answer, I will take that into account for my
code and look in PDO code to fix that.
Ludovic
On 5/4/06, Wez Furlong <kingwez@gmail.com> wrote:
There is no guarantee that the class will exist in subsequent requests, making it unsafe to use. Eg: file1.php: class Foo extends PDOStatement {} $db = new PDO($dsn, $user, $pass, array(PDO::ATTR_PERSISTENT=>true)); $db->setAttribute(PDO::ATTR_STATEMENT_CLASS, 'Foo'); then in a separate request (to that same apache child process): file2.php: $db = new PDO($dsn, $user, $pass, array(PDO::ATTR_PERSISTENT=>true)); // $db is still referencing a stale pointer to the // Foo class entry from the last request. // this ->query call will crash PHP $stmt = $db->query($sql); This can be fixed, it just hasn't happened yet. In the meantime, we don't let you do it. --Wez. On 5/4/06, Ludovic Levesque <luddic@gmail.com> wrote: Hi everybody, can someone on the list explain me why "PDO::ATTR_STATEMENT_CLASS cannot be used with persistent PDO instances" ? line 707 of pdo_dbh.c:if (dbh->is_persistent) { pdo_raise_impl_error(dbh, NULL, "HY000", "PDO::ATTR_STATEMENT_CLASS cannot be used withpersistent PDO instances"TSRMLS_CC); PDO_HANDLE_DBH_ERR(); RETURN_FALSE; }When I test with code commented, nothing fails. Thanks, Ludovic -- PECL development discussion Mailing List (http://pecl.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php