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 #6700

Naming Convention For Table Fields (Class Properties)

Details

Request #6700Naming Convention For Table Fields (Class Properties)
Submitted2006-02-05 23:24 UTC
Frommz+pear at dago dot de
StatusWont fix
PackageDB_DataObject
PHP VersionIrrelevant
OSLinux
Roadmaps(Not assigned)

Comments

[2006-02-05 23:24 UTC] mz+pear at dago dot de

Description:
------------
The createTable-Script returns Field Names in the way they are used in Database.
It would be nice, if they'll have names like the Hungarian Notation, for example company_user_id changes to companyUserId. This is a kind of standard in object-oriented programming, so it should also be used in DB/DataObject.

Test script:
---------------
A dirty hack for that:

At 'DB/DataObject/Generator.php'

375 foreach($defs as $t) {
376 $name = str_replace('_', ' ', $t->name);
377 $t->name = str_replace(' ', '', lcfirst(ucwords($name)));
378
379 $n=0;

[2006-02-05 23:30 UTC] mz+pear at dago dot de

I'm sorry there's no function called lcfirst, so it has to be something like:

376 $name = str_replace('_', ' ', $t->name);
377 $name = strtolower($name[0]) . ucwords($name);
378 $t->name = str_replace(' ', '', $name);

... but I think, it should be provided in an extra method of course.

[2006-02-05 23:38 UTC] mz+pear at dago dot de

Oh dear ... it's too late for this ... I need bugfixes for bugfixes ;(=

375 foreach($defs as $t) {
376 $name = str_replace('_', ' ', $t->name);
377 $name = strtolower($name[0]) . substr(ucwords($name), 1);
378 $t->name = str_replace(' ', '', $name);
379
380 $n=0;

This will be the last one, I promise ;)=