[CDBI] Re: Can CDBI do this?

Matt S Trout dbix-class at trout.me.uk
Thu Jan 19 22:14:15 GMT 2006

On Thu, Jan 19, 2006 at 04:45:54PM -0500, Edward J. Sabol wrote:
> Ben Lavender asked about the following:
> >>> SELECT events.(essential) FROM events, certs WHERE ( events.duedate <
> >>> "2999-01-01" AND certs.id = events.cert AND certs.type = "Some String I
> >>> Input") ORDER BY dueDate LIMIT 10;
> Bill Moseley replied:
> >> Look at CDBI::Sweet;
> Will Hawes replied:
> > Or better still, switch to DBIx::Class.
> Frankly, you don't need to do either one. Yes, CDBI can do this. Read the
> CDBI docs on the set_sql method:

This is, admittedly, true. You don't *need* to do either one. But your life
will be far easier if you do, unless you like writing an extra SQL query
every single time you need to change the arguments. And embedding SQL queries
willy-nilly in your object class, so you've now got two languages to worry
about instead of one.

I spent a long time doing set_sqls. Eventually I gave up and wrote the Sweet
join support instead, and my maintainability shot up. YMMV, but that's my
experience - and the reason why when I hit the ceiling of what CDBI could
cope with via subclassing, I started DBIx::Class to replace it (for values
of "replace" meaning "in my code" - I think it's a massive improvement on
CDBI, but I have no issue with people disagreeing with me on that :)

     Matt S Trout       Offering custom development, consultancy and support
  Technical Director    contracts for Catalyst, DBIx::Class and BAST. Contact
Shadowcat Systems Ltd.  mst (at) shadowcatsystems.co.uk for more information

 + Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +

More information about the ClassDBI mailing list