similar idea here:
http://search.cpan.org/src/KARMAN/Catalyst-Controller-Rose-0.03/t/examples/CatRose/make_rdbo_classes.pl
Jonathan Vanasco wrote on 6/15/07 8:54 PM:
> On Jun 15, 2007, at 6:40 PM, Jeffrey Horn wrote:
>
>> I'm wondering if there's any code out there that will generate
>> Rose::DB::Object's for all tables in a database. I have my own
>> makeshift
>> version which will do it for a given table, and the loop to simply
>> iterate
>> through tables isn't bad. I'm wondering if there's something that
>> will
>> create all the FK mappings for me, which would probably imply that
>> it would
>> also do some sort of DAG analysis on the table dependencies.
>>
>> Any help in that direction would be appreciated!
>>
>> Thanks!
>
> see below!
>
> it can take some time to work
>
> ##############################################
>
> use warnings;
> use strict;
>
> package MyApp::RoseDB;
> use Rose::DB ();
> use base qw(Rose::DB);
> __PACKAGE__->use_private_registry;
> __PACKAGE__->default_domain('main');
> __PACKAGE__->default_type('main');
> __PACKAGE__->register_db(
> domain => 'main',
> type => 'main',
> driver => 'Pg',
> database => 'myapp',
> host => 'localhost',
> username => 'myapp',
> password => 'myapp',
> );
>
> ###############################################
>
> package MyApp::RoseDB::Object;
> use base qw(Rose::DB::Object);
> sub init_db { MyApp::RoseDB->new };
>
> ###############################################
>
>
> package main;
> use Rose::DB::Object::Loader;
> my $loader= Rose::DB::Object::Loader->new(
> db=> MyApp::RoseDB->new('main'),
> class_prefix=> 'MyApp::RoseDB::Object'
> );
>
> $loader->make_modules(
> module_dir=> '/rose',
> with_foreign_keys=> 1,
> with_relationships=> 1
> );
>
>
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> Rose-db-object mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/rose-db-object
--
Peter Karman . http://peknet.com/ . [EMAIL PROTECTED]
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Rose-db-object mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rose-db-object