|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-08-30 23:26 UTC] wez@php.net
[2005-09-01 09:26 UTC] akorthaus at web dot de
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Dec 22 20:00:01 2025 UTC |
Description: ------------ If you want to use an own Statement-Class which should be returned by PDO::prepare(), you have to do it this way: $pdo->prepare($sql, array(PDO_ATTR_STATEMENT_CLASS=>array('MyStatementClass'))); see: http://cvs.php.net/co.php/php-src/ext/pdo/tests/pdo_023.phpt You have to write that everywhere in your code and it's not possible to use 'MyStatementClass' with PDO::query(). What about implementing an attribute which could be set by PDO::setAttribute(), which makes it possible to set the Statement Class once at the beginning of the script? As side effect other methodes like PDO::query() could use that attribute and return the same class. Any chance to see something like that in PHP 5.1? Btw.: why is the value of PDO_ATTR_STATEMENT_CLASS of type array and not string? Expected result: ---------------- I think that would be very useful: class MyStatementClass extends PDOStatement { // my adds/changes ... } $pdo->setAttribute( array( PDO_ATTR_STATEMENT_CLASS => 'MyStatementClass' ) ); $pdo->prepare($sql); // will return a MyStatementClass object $pdo->query($sql); // will return a MyStatementClass object too ... Actual result: -------------- The way it is today: class MyStatementClass extends PDOStatement { // my adds/changes ... } $pdo->prepare($sql, array( PDO_ATTR_STATEMENT_CLASS=>array('MyStatementClass')) ); // will return a MyStatementClass object $pdo->query($sql); // will not return a MyStatementClass object $pdo->prepare($sql); // will not return a MyStatementClass object too