Bug #16519 [Opn->Bgs]: Options in DB_DataObject not passed in MDB2 if used as Driver
| From: | alan at akbkhome dot com | Date: | Mon, 28 Sep 2009 00:32:35 +0000 |
| Subject: | Bug #16519 [Opn->Bgs]: Options in DB_DataObject not passed in MDB2 if used as Driver | ||
| References: | 1 | Groups: | php.pear.bugs |
| Request: | Send a blank email to pear-bugs+get-1747@lists.php.net to get a copy of this message | ||
Edit report at http://pear.php.net/bugs/bug.php?id=16519&edit=1
ID: 16519
Updated by: alan@akbkhome.com
Reported By: jerome dot auza at mfgvision dot com
Summary: Options in DB_DataObject not passed in MDB2 if used
as Driver
-Status: Open
+Status: Bogus
Type: Bug
Package: DB_DataObject
Operating System: Linux
PHP Version: 5.2.5
Roadmap Versions:
New Comment:
-Status: Open
+Status: Bogus
Thank you for taking the time to write to us, but this is not
a bug.
this is the code that does the MDB2 connection
require_once 'MDB2.php';
// this allows the setings of compatibility on MDB2
$db_options = PEAR::getStaticProperty('MDB2','options');
$db_options = is_array($db_options) ? $db_options :
array();
$db_options['portability'] =
isset($db_options['portability'] )
? $db_options['portability'] : MDB2_PORTABILITY_ALL ^
MDB2_PORTABILITY_FIX_CASE;
$_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5] =
&MDB2::connect($dsn,$db_options);
So to use it you need to do this:
$options = &PEAR::getStaticProperty('MDB2','options');
$options = array(
'field_case' => CASE_UPPER,
'portability' => MDB2_PORTABILITY_ALL,
);
Previous Comments:
------------------------------------------------------------------------
[2009-09-27 11:00:22] quipo
-Package: MDB2
+Package: DB_DataObject
------------------------------------------------------------------------
[2009-08-13 10:39:39] jjauza
Description:
------------
Options specifed in DB_DataObject are not passed to MDB2 object if MDB2
is used as Driver.
A fix I used on my code to get this working is the following although
I'm not sure if this is the right way to do it:
in MDB2.php, near line 4295 :
function &getDBInstance()
{
if (isset($GLOBALS['_MDB2_databases'][$this->db_index])) {
$result =& $GLOBALS['_MDB2_databases'][$this->db_index];
// Fix for DB_DATAOBJECT options not passed to MDB2
foreach($GLOBALS['_DB_DATAOBJECT']['CONFIG'] as
$key=>$value) {
$result->options[$key]=$value;
}
// end of fix
} else {
$result =& MDB2::raiseError(MDB2_ERROR_NOT_FOUND, null,
null,
'could not find MDB2 instance');
}
return $result;
}
Test script:
---------------
<?php
include_once("MDB2.php");
include_once("DB/DataObject.php");
$options =
&PEAR::getStaticProperty('DB_DataObject','options');
$options = array(
'database' => DSN_TO_YOUR_DB,
'class_prefix' => 'DataObjects_',
'proxy' => 'full',
'field_case' => CASE_UPPER,
'portability' => MDB2_PORTABILITY_ALL,
'debug' => 5,
'db_driver' => 'MDB2',
);
$tbl = DB_DataObject::factory('table_name');
print_r($GLOBALS['_MDB2_databases']);
print_r($GLOBALS['_DB_DATAOBJECT']['CONFIG']);
Expected result:
----------------
the array values in $GLOBALS['_DB_DATAOBJECT']['CONFIG'] should be
found in the options array in $GLOBALS['_MDB2_databases']
Actual result:
--------------
The options field $GLOBALS['_MDB2_databases'] seem to be just default
option values.and none of the options specified in the sample code are
passed.
------------------------------------------------------------------------
--
Edit this bug report at http://pear.php.net/bugs/bug.php?id=16519&edit=1