As said before,
DBIx::Class (
DBIx::Class::Loader) does all that and much more, it also requires less code than your Rails example btw.
package MyApp::Model::DBIC;
use strict;
use base 'Catalyst::Model::DBIC';
__PACKAGE__->config(
dsn => 'dbi:SQLite:/Users/sri/MyApp/test.db',
relationships => 1
);
1;
Thats all you need, table classes are generated and releationships auto-detected by analyzing foreign keys.
You don't even have to write it by hand,
Catalyst has helpers to do it for you. ("script/myapp_create.pl model DBIC DBIC dbi:SQLite:/Users/sri/MyApp/test.db")
Bundle::Catalyst suggests only
DBIx::Class, definitely not Class::DBI.
Yes Ruby looks a bit cleaner in "your" examples, but bad programmers write bad code in any language.
Ruby is also missing a lot that disqualifies it for me, especially Multiple Inheritance, i like
NEXT and
Class::C3 very much. (mixins are no alternative!)
Not to mention the bad performance and lack of modules...
So what exactly can't be written in Perl?!?!
Do you really think a tight integrated framework for Perl makes sense? Why?
The Perl community is very fragmented, we have many alternatives(TIMTOWTDI), TT, HTML::Mason, HTML::Template, DBIx::Class, Tangram, Alzabo, SPOPS... which two components would you choose for tight integration? They all have their strengths and weaknesses, so why not choose the best for the task at hand? Why not use multiple template engines, multiple orm's in the same application?
So far i've not even seen a single Rails app dealing with more than one database!
Oh, did i mention
Catalyst now also supports
PAR, ship all prereqs with your app, something Rails people can only dream of...
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.