Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 0.8.6

Bug #11920 After database creation, sqlite db connection not usable
Submitted: 2007-08-28 11:11 UTC
From: cweiske Assigned: ifeghali
Status: Closed Package: MDB2_Schema (version 0.8.0)
PHP Version: 5.2.3 OS:
Roadmaps: (Not assigned)    
Subscription  


 [2007-08-28 11:11 UTC] cweiske (Christian Weiske)
Description: ------------ I don't know if that is a bug in MDB2's sqlite driver or MDB2_Schema: - I create an MDB2 connection object - I create an MDB2_Schema object, passing the connection object - After loading a database schema, the mdb2 connection object is unusable because its connection property is "int(0)" instead of "resource(469) of type (sqlite database)". The connection is set to int(0) by MDB2_Schema calling setDatabase("") on line 1030. On line 1065 it is set back, but the connection is still 0. No database is selected

Comments

 [2007-08-28 11:26 UTC] cweiske (Christian Weiske)
It has to do with SQLite not supporting databases since a file is a database. So in sqlite's case, no database should be set or changed.
 [2007-08-28 12:54 UTC] cweiske (Christian Weiske)
MDB2_Schema should check if the driver supports changing multiple databases and use setDatabase() only if. See bug #11922 for this.
 [2007-08-29 15:31 UTC] ifeghali (Igor Feghali)
Hello Christian, thank you for submitting this bug. I am gonna work on this by the end of next weekend. regards, iGor.
 [2007-09-10 03:49 UTC] ifeghali (Igor Feghali)
We are unable to reproduce the bug as reported. Please provide a simple script (10 lines or less) or a link to an external script that can be used to reproduce the bug. If you can provide the script, feel free to add it to this bug and change the status back to "Open". Thank you for your interest in PEAR. Hello Christian, I tried with that script and everything went fine: <? require 'MDB2/Schema.php'; $dsn = 'sqlite://localhost/'; $db = MDB2::factory($dsn, null); if (PEAR::isError($db)) { die('MDB2: ' . $db->getMessage() .' : '. $db->getUserInfo()); } $schema =& MDB2_Schema::factory($db, null); if (PEAR::isError($schema)) { die('factory(): ' . $schema->getMessage() .' : '. $schema->getUserInfo()); } $definition = $schema->parseDatabaseDefinition('schema.xml', false, array(), false); if (PEAR::isError($definition)) { die('def: ' . $definition->getMessage() .' : '. $definition->getUserInfo()); } else { $status = $schema->createDatabase($definition); if (PEAR::isError($status)) { die('create: '.$status->getMessage() .' : '. $status->getUserInfo()); } } ?> by "line 1030 and 1065" you mean lines of Schema.php ? Are you sure those numbers are correct ? regards, iGor.
 [2007-12-11 20:43 UTC] cweiske (Christian Weiske)
<?php require_once 'MDB2.php'; require_once 'MDB2/Schema.php'; $tmpfname = tempnam(sys_get_temp_dir(), 'mdb2schema'); $dsn = 'sqlite:///' . $tmpfname; $dsnSource = dirname(__FILE__) . '/rap.mdb2schema'; $db = MDB2::connect($dsn); if (PEAR::isError($db)) { die($db->getMessage() . "\n"); } $schema = MDB2_Schema::factory($db); if (PEAR::isError($schema)) { die($schema->getMessage() . "\n"); } $definition = $schema->parseDatabaseDefinitionFile($dsnSource); $op = $schema->createDatabase($definition, array(), false); $e = $db->query('SELECT COUNT(*) FROM datasets'); echo $e; /* Warning: sqlite_last_error() expects parameter 1 to be resource, integer given in /home/cweiske/Dev/cvs/pear/instpear/share/pear/MDB2/Driver/sqlite.php on line 532 Catchable fatal error: Object of class MDB2_Error could not be converted to string in /home/cweiske/Dev/cvs/pear/mdb2schemabug.php on line 23 */ ?>
 [2008-01-30 11:14 UTC] ifeghali (Igor Feghali)
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.