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

Database prefixes in auto generated classes

Details

Request #3765Database prefixes in auto generated classes
Submitted2005-03-10 14:56 UTC
Fromtherion_5 at hotmail dot com
StatusSuspended
PackageDB_DataObject
PHP Version4.3.10
OSAny
Roadmaps(Not assigned)

Comments

[2005-03-10 14:56 UTC] therion_5 at hotmail dot com

Description:
------------
If i want to use multiple databases, which has similar tables then autogenerator will overwrite class definition from first database with table from latest database.

I think it should be possible to define class prefix for each database. We need two support two modified properties class_location_* and class_prefix_*

database_foo = mysql://.../foo
database_bar = mysql://.../bar

class_prefix_foo = FOO_
class_prefix_bar = BAR_

class_location_foo = ...
class_location_bar = ...

...

After that it should be possible to load tables by appending to them after '@' database name

$foo_user = DB_DataObject::factory('user@foo');
$bar_user = DB_DataObject::factory('user@bar');

I have changed my local DB_DataObject and Generator classes ... it works without visible side-effects. Please contact me by email and I will provide changed scripts.

[2005-03-15 08:23 UTC] therion_5 at hotmail dot com

can't send you on alan@akbkhome.com (Delivery delayed). Please give me another email

[2005-05-25 08:38 UTC] therion_5 at hotmail dot com

Give me more information, i have no probs with my implementation, it works for me fine.

If you want to follow DBDO guidelines then we have to think about additional argument for several methods.

After that i can try to fix it in current version.

[2005-08-24 17:15 UTC] robert at osuosl dot org

I was on here looking to recommend almost this exact patch. It would be a wonderful feature. I'm just curious what the status of this is, since the last comment was in May.

Thanks.

[2005-09-05 14:30 UTC] developer at ckiweb dot com

Just wanted to let you know that I would like this implemented. I took the diff you gave and inserted it into my code, and things look to be running pretty good. I am wondering if you are plannig to implement this in with the calling format as table@database, or as 'table', 'database' (2 arguments)? Thanksg.

[2005-09-06 09:57 UTC] therion_5 at hotmail dot com

Yeah it would be nice to implement it like Alan suggested, but I have implemented it before i heard it from him, and after that i had no real time(need) to reimplement it again, BUT it should be really not a problem. Just one thing ... it will possibly affect existing code, because currently we are using DB_DataObject::factory('tablename') ... and switching to DB_DataObject::factory('databasealias', 'tablename'). If it's not a problem i would suggest DB_DataObject::factory('tablename','databasealias'), where second param is optional.

So actually we are waiting for Alan decision, if he accept it and may be specify some requirements, then no prob we can implement it in actual version :)