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

Bug #8799 DB/common.php required
Submitted: 2006-09-27 14:31 UTC
From: christophe dot laratte at openflyers dot org Assigned: lukasfeiler
Status: Closed Package: XML_Query2XML (version 0.6.0)
PHP Version: 5.0.0 OS: Windows
Roadmaps: (Not assigned)    
Subscription  


 [2006-09-27 14:31 UTC] christophe dot laratte at openflyers dot org (Christophe LARATTE)
Description: ------------ Hi (and thanks for your work), It's impossible to use PEAR::XML_Query2XML without PEAR::DB. Because line 132 of Query2XML.php there is this test : if ($db instanceof DB_common) { So I reached to short-cut the bug by adding this line at the beginning of my script : require_once ('DB/common.php'); But it's not I good deal! Therefore that "This package [DB] been superseded by MDB2 but is still maintained for bugs and security fixes" So, if I use MDB2, I'd like not to install DB ;-) Maybe this patch is correct : private function __construct($db) { $parentName = get_parent_class($db); if ($parentName == 'DB_common') { $this->_isMDB2 = false; $this->_db = $db; } elseif ($parentName == 'MDB2_Driver_Common') { $this->_isMDB2 = true; $this->_db = $db; } elseif (PEAR::isError($db)) { throw new XML_Query2XML_DBException( 'Could not connect to database: ' . $db->toString() ); } else { throw new XML_Query2XML_ConfigException( 'Argument passed to the XML_Query2XML constructor is not an ' . 'instance of DB_common or MDB2_Driver_Common.' ); } if ($this->_isMDB2) { $fetchModeError = $this->_db->setFetchMode(MDB2_FETCHMODE_ASSOC); } else { $fetchModeError = $this->_db->setFetchMode(DB_FETCHMODE_ASSOC); } if (PEAR::isError($fetchModeError)) { throw new XML_Query2XML_DBException( 'Could not set fetch mode to FETCHMODE_ASSOC: ' . $fetchModeError->toString() ); } } Good job ! Test script: --------------- <?php require_once('XML/Query2XML.php'); require_once('MDB2.php'); $db =& MDB2::connect(DBTYPE.'://'.VISITOR.':'.PASSWORD_VISITOR.'@'.HOST.'/'.BASE, $dboptions); $query2xml = XML_Query2XML::factory($db); ?> Expected result: ---------------- Nothing ;-) Actual result: -------------- Fatal error: Class 'DB_common' not found in d:\php\of2\pear\XML\Query2XML.php on line 132

Comments

 [2006-09-27 21:17 UTC] lukasfeiler at php dot net (Lukas Feiler)
Thanks a lot for reporting this! I'll fix this tomorrow.
 [2006-09-27 21:18 UTC] lukasfeiler at php dot net (Lukas Feiler)
Thanks a lot for reporting this! I'll fix this tomorrow.
 [2006-09-28 10:34 UTC] lukasfeiler at php dot net (Lukas Feiler)
Thank you for your bug report. This issue has been fixed in the latest released version of the package, which you can download at http://pear.php.net/get/XML_Query2XML
 [2006-09-29 07:34 UTC] christophe dot laratte at openflyers dot org
Perfect !