DB_DataObject get*() and case of field name
| From: | Dieter Erdmann | Date: | Sat, 05 Mar 2005 16:50:57 +0000 |
| Subject: | DB_DataObject get*() and case of field name | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-17869@lists.php.net to get a copy of this message | ||
I use the PEAR DataObject class under PHP5. The table corresponding to my
DataObject has a field named 'count'. I want to access this field on a
DataObject 'myObj' with the get*() auto accessor:
$myCount = $myObj->getCount();
However, this yields the following warning:
Warning: PHP5 set/get calls should match the case of the variable in
/usr/local/php5/lib/php/DB/DataObject.php on line 3147
Obviously, since the field name is 'count' rather than 'Count', the DataObject
expects the following statement:
$myCount = $myObj->getcount();
What's the deal with this warning? Is there a way to change this behavior (so
that DataObject accepts 'getCount()')? As the warning message says, this
seems to be a PHP5-specific 'problem'. Judging by the examples given in the
DataObject documentation, the 'getCount()' usage is legal (the example uses a
field named 'name' and an accessor named 'getName()'), so why wasn't it
implemented this way?
thx
Dieter