PEAR is archived and read-only

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

Home » Database » DB_DataObject_FormBuilder » Bug #3164

Use of DB_DataObject_Cast use should be removed or optional

Details

Request #3164Use of DB_DataObject_Cast use should be removed or optional
Submitted2005-01-11 16:02 UTC
Fromate2 at cornell dot edu
Assignedjustinpatrin
StatusBogus
PackageDB_DataObject_FormBuilder
PHP VersionIrrelevant
OSIrrelevant
Roadmaps(Not assigned)

Comments

[2005-01-11 16:02 UTC] ate2 at cornell dot edu

Description:
------------
As far as I can tell, DB_DataObject_Cast is used only twice in the class and in both cases it is used to pass an sql NULL. This seems unnecessary since DB_DataObject already sets fields to null if they are allowed to be null, have no default value (determined by db backend), and return a false when passed through the isset() method (not set or are set to php null). Unless there are specific situations where this casting would be necessary, I'd propose removing casting altogether. Otherwise, maybe another class property to allow disabling cast.

Reproduce code:
---------------
$do =& new DB_DataObject();
$fb =& new DB_DataObject_FormBuilder($do);
$form =& $fb->getForm();
if ($form->validate()) {
$do->processForm();
if (empty($do->field)) {
echo "Field is not set.";
}
else {
echo "Field is set to value {$do->field}.";
}
}
echo $form->toHtml();

Expected result:
----------------
"Field is not set."

Actual result:
--------------
"Field is set to value Object."