PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Structures » Structures_DataGrid » Bug #4874

DB_DataObject getter function naming problem

Details

Submitted2005-07-21 07:39 UTC
Fromevt at infoware dot com dot au
Assignedasnagy
StatusClosed
PackageStructures_DataGrid
PHP Version5.0.3
OSSuse Linux
Roadmaps(Not assigned)

Comments

[2005-07-21 07:39 UTC] evt at infoware dot com dot au

Description:
------------
DB_DataObject generator names setter/getter function with the column name, and sets the first letter to uppercase, eg. menus_id_pf is named getMenus_id_pf(). In the module DataSource/DataObject.php this is not taken into consideration, ie it tries to call getmenu_id_pf instead of getMenus_id_pf. Also the call is missing ().

Test script:
---------------
foreach ($fieldList as $fName) {
$getMethod = 'get'.$fName;
if (method_exists($this->_dataobject, $getMethod)) {
//$rec[$fName] = this->_dataobject->$getMethod(&$this);
$rec[$fName] = $this->_dataobject->$getMethod;
} elseif (isset($this->_dataobject->$fName)) {
$rec[$fName] = $this->_dataobject->$fName;
} else {
$rec[$fName] = null;
}
}

Should be (modified line with ***):

foreach ($fieldList as $fName) {
$getMethod = 'get'.ucfirst($fName); // ***
if (method_exists($this->_dataobject, $getMethod)) {
//$rec[$fName] = this->_dataobject->$getMethod(&$this);
$rec[$fName] = $this->_dataobject->$getMethod(); //***
} elseif (isset($this->_dataobject->$fName)) {
$rec[$fName] = $this->_dataobject->$fName;
} else {
$rec[$fName] = null;
}
}