Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Re: Getting HASHES out of Class::DBI

by jdtoronto (Prior)
on Jan 07, 2004 at 02:18 UTC ( [id://319322]=note: print w/replies, xml ) Need Help??


in reply to Re: Getting HASHES out of Class::DBI
in thread Getting HASHES out of Class::DBI

I'd have to ask, what do you need the hash for? If you really do need a hash, then yes, why are you using CDBI? Ideally you want to use the object, not the hash.
Well, now you mention it. HTML::Template takes hashes, Data::FormValidate returns hashes, HTML::FillInForm takes hashes, or these tajke hashrefs, whatever. But it seems that everything I am using for validation and output wants hashes. So, indeed, why am I using Class::DBI. Class::DBI was represented as being "the way" to handle data intensive web-apps. But I am beginning to doubt that now. For small databases, few fields (some of my tables have 100-120 fields) and few relationships Class::DBI is great (my test application for example!), but as I have tried to move it into the big league here it is suffering.

I am quite prepared for someone to tell me it is me that doesn't know how to do things, I am totally new at OO Perl! But I think I am wasting too much time trying to get CDBI shoe-horned into my app right now.

jdtoronto

  • Comment on Re: Re: Getting HASHES out of Class::DBI

Replies are listed 'Best First'.
Re: Re: Re: Getting HASHES out of Class::DBI
by perrin (Chancellor) on Jan 07, 2004 at 04:17 UTC
    If you are going to use objects to access a database, then Class::DBI will typically make that easier and save you code. Before I started using it, I would write my own data access objects from scratch. Class::DBI has made that unnecessary, or at least removed the boring parts of it.

    I don't think that the usefulness of Class::DBI for a particular application has much to do with the size or complexity of your database. I do think it has a lot to do with your approach to coding and whether or not you like accessing your data as objects.

    When I've used Class::DBI with HTML::Template, I found it pretty easy to copy data from a list of objects into a hash structure that H::T could handle. I definitely was writing code to handle that translation, but that's the price you pay for the strong abstraction layer that H::T provides you. If you want a templating system that doesn't require you to arrange your data like this, Template Toolkit is happy to work on Class::DBI objects directly.

      When I've used Class::DBI with HTML::Template, I found it pretty easy to copy data from a list of objects into a hash structure that H::T could handle. I definitely was writing code to handle that translation, but that's the price you pay for the strong abstraction layer that H::T provides you. If you want a templating system that doesn't require you to arrange your data like this, Template Toolkit is happy to work on Class::DBI objects directly.
      Well perrin I think you have hit it on the head. I thought again about my remarks on DB complexity. Perhaps Class::DBI is no more and no less capable of handling complex relationships than anything else. What I was complaining about was the translation, and I think a couple of suggestions have been made that I will ponder overnight.

      As always, thanks for the insightful contribution.

      John jdtoronto

      PS: Template Toolkit is on my list of things to learn when this job is complete!

Re: Re: Re: Getting HASHES out of Class::DBI
by knowmad (Monk) on Jan 07, 2004 at 13:36 UTC

    Have you tried passing the CDBI object into HTML::Template? It's just like passing in a reference to a list or hash. This is how I send database results into my templates (I'm using Petal however).

    William

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://319322]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2024-04-25 11:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found