On 3/1/06 12:47 AM, Ron Savage wrote:
> On Wed, 01 Mar 2006 00:05:02 -0500, John Siracusa wrote:
>> On 2/28/06 11:34 PM, Ron Savage wrote:
>>> When it says: "Here's a complete example..." how exactly do I
>>> tell the code to connect to a registry entry so as to read the
>>> metadata from the database?
>>
>> Er, tell what code? The loader? A call to auto_initialize() from
>> within a class? Something else?
>
> Tell my code, as based on the docs. Eg:
>
> #!/usr/bin/perl
> # generate-class-code.pl.
>
> package AcademicTitle;
>
> our @ISA = 'Rose::DB::Object';
>
> __PACKAGE__ -> meta -> table('academic_title');
> __PACKAGE__ -> meta -> auto_initialize;
You need to override init_db, either in each RDBO-derived class or (the
recommended approach) in a common base class that all your classes inherit
from. For example:
package MyBaseClass;
use MyDB; # "isa" Rose::DB and has dbs registered
use base 'Rose::DB::Object';
sub init_db { MyDB->new }
# or...
# sub init_db { MyDB->new('some_db_type') }
# or...
# sub init_db { MyDB->new(domain => 'foo', type => 'bar') }
1;
And then do this:
package AcademicTitle
use base 'MyBaseClass';
...
package Faculty
use base 'MyBaseClass';
...
Look in all three of these places for more info (so many docs, I know... :)
http://search.cpan.org/dist/Rose-DB/lib/Rose/DB/Tutorial.pod
http://search.cpan.org/dist/Rose-DB-Object/lib/Rose/DB/Object/Tutorial.pod#A
_brief_digression%3A_database_objects
http://search.cpan.org/dist/Rose-DB-Object/lib/Rose/DB/Object/Tutorial.pod#M
ainstream_usage
-John
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Rose-db-object mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rose-db-object