PEAR is archived and read-only

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

Home » Database » DB_DataObject » Bug #3812

DB_Dataobject casts every column to string datatype

Details

Request #3812DB_Dataobject casts every column to string datatype
Submitted2005-03-14 22:29 UTC
Fromananomouse1 at yahoo dot com
StatusSuspended
PackageDB_DataObject
PHP Version4.3.4
OSWin XP
Roadmaps(Not assigned)

Comments

[2005-03-14 22:29 UTC] ananomouse1 at yahoo dot com

Description:
------------
Using DB_DataObject all columns are returned from database as a string datatype. Ie, dates, floats, etc. are created as strings within the DB_Dataobject child object.

Version info:
DB_DataObject = 1.7.9
DB = 1.7.4

One potential unusual thing: I have defined my own base which extends DB_DataObject. All of my dataobjects extend my class. However, I see nothing in my base class which would cause this to be happening.

Reproduce code:
---------------
function getCouponInfo($coupon) {

// create new DO coupon object
$couponDO = DB_DataObject::factory('Coupon');

if(PEAR::isError($couponDO)) {
PEAR::raiseError('Error creating Coupon object. getCouponInfo', PEAR_LOG_ERR);
}

if(is_scalar($coupon)) {
$couponDO->get($coupon);
} else {
// associative array passed in, grab key & value
$keyValue = each($coupon);
$couponDO->get($keyValue['key'],$keyValue['value']);
}


$couponInfo = $couponDO->toArray();
return $couponInfo;
}

[2005-03-15 15:00 UTC] ananomouse1 at yahoo dot com

Sorry, perhaps I misunderstood the functionality of DB_DataObject. This page from the documentation seemed to imply (to me) that the DO casts each DB column to its PHP-appropriate type. For instance:
[id] => 12
[group] => 5

These are not strings (do not have quotes).

http://pear.php.net/manual/en/package.database.db-dataobject.db-dataobject.get.php

Also, I note that the actual classes created by the createTables script have the column type stored as comments. I thought this might be used to cast the column to its php-appropriate type. Do I misunderstand something?