From: Operating system: Win7 - CentOS 5 PHP version: 5.3.3 Package: PDO related Bug Type: Bug Bug description:PDO warpped by Singleton-Factory Class does not INSERT/DELETE/ InnoDB Engine
Description: ------------ I've spent a couple days trying to figure why and no success so far: Wrapping PDO with a Singleton or a Factory class for easy driver switching does not INSERT/DELETE/UPDATE on MySQL InnoDB engine. SELECT statements works fine and if switch to MyISAM everything works as expected. PHP 5.3.1 up to 5.3.3 (Namespaced classes) MySQL version 5.1 (tested on all builds) Windows 7 and CentOS5 Apache 2.2 Test script: --------------- <?php namespace Subroutine; use FW\CFG; class Data{ private static $instance = NULL; public static $DRIVER = NULL; /** * @return PDO */ public static function connect(){ if (self::$instance === NULL): $username = NULL; $passwd = NULL; $options = array(); self::$DRIVER = strtolower(CFG::key()->_DB['DRIVER']); switch (self::$DRIVER): case 'mysql': $dsn = self::$DRIVER . ':host=' . CFG::key()->_DB['HOST'] . ';dbname=' . CFG::key()->_DB['SCHEMA']; $username = CFG::key()->_DB['USER']; $passwd = CFG::key()->_DB['PASS']; $options = array( CFG::key()->_DB['OPTIONS'] ); break; //Other drivers not implemented yet endswitch; try{ self::$instance = new \PDO($dsn, $username, $passwd, $options); } catch(PDOException $e){ echo $e->getMessage(); return; } endif; return self::$instance; } } ?> Expected result: ---------------- <?php namespace Model; use Subroutine\Data; class MyModel{ public function init(){ $m = Data::connect(); $m->exec("INSERT INTO sessions (id, data, expires) VALUES (123,'my data',1234567890)"); } } ?> Expects to INSERT in MySQL InnoDB engine. Actual result: -------------- Does not INSERT/DELETE/UPDATE in MySQL InnoDB. -- Edit bug report at http://bugs.php.net/bug.php?id=53247&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=53247&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=53247&r=trysnapshot53 Try a snapshot (trunk): http://bugs.php.net/fix.php?id=53247&r=trysnapshottrunk Fixed in SVN: http://bugs.php.net/fix.php?id=53247&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=53247&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=53247&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=53247&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=53247&r=needscript Try newer version: http://bugs.php.net/fix.php?id=53247&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=53247&r=support Expected behavior: http://bugs.php.net/fix.php?id=53247&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=53247&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=53247&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=53247&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=53247&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=53247&r=dst IIS Stability: http://bugs.php.net/fix.php?id=53247&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=53247&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=53247&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=53247&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=53247&r=mysqlcfg