FAQ
Edit report at http://pear.php.net/bugs/bug.php?id=16519&edit=1

ID: 16519
Updated by: l.alberton@quipo.it
Reported By: jerome dot auza at mfgvision dot com
Summary: Options in DB_DataObject not passed in MDB2 if used
as Driver
Status: Open
Type: Bug
-Package: MDB2
+Package: DB_DataObject
Operating System: Linux
Package Version: 2.4.1
PHP Version: 5.2.5
Roadmap Versions:
New Comment:

-Package: MDB2
+Package: DB_DataObject



Previous Comments:
------------------------------------------------------------------------

[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.

------------------------------------------------------------------------

Search Discussions

  • Alan at Sep 27, 2009 at 11:32 pm
    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.

    ------------------------------------------------------------------------
  • Alan at Sep 27, 2009 at 11:33 pm
    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: Bogus
    Type: Bug
    Package: DB_DataObject
    Operating System: Linux
    PHP Version: 5.2.5
    Roadmap Versions:
    New Comment:

    BTW = please make a note somewhere in the manual where you feel that it
    is relivant about this behaviour.


    Previous Comments:
    ------------------------------------------------------------------------

    [2009-09-28 01:32:34] alan_k

    -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,
    );

    ------------------------------------------------------------------------

    [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.

    ------------------------------------------------------------------------

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppear-bugs @
categoriesphp
postedSep 27, '09 at 9:00a
activeSep 27, '09 at 11:33p
posts3
users2
websitepear.php.net

2 users in discussion

Alan: 2 posts L Alberton: 1 post

People

Translate

site design / logo © 2022 Grokbase