Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^2: Class::DBI -- does it get any easier?

by drewbie (Chaplain)
on Nov 12, 2004 at 15:35 UTC ( [id://407384]=note: print w/replies, xml ) Need Help??


in reply to Re: Class::DBI -- does it get any easier?
in thread Class::DBI -- does it get any easier?

Regarding Class::DBI::Loader, I've briefly looked at it before and thought it looked very handy (especially in introducing Class::DBI for a large number of existing tables). But does this work if you need custom logic in the module in addition to the basic column/relationship definitions? Can you still define My::TableName as a package, add the logic there, and have perl see it automagically? It's still unclear after reading the docs and code.
  • Comment on Re^2: Class::DBI -- does it get any easier?

Replies are listed 'Best First'.
Re^3: Class::DBI -- does it get any easier?
by geektron (Curate) on Nov 12, 2004 at 17:04 UTC
    as i understand it ( and i'm not an expert on it by any means ), there are easy ways to override behaviours if needed, some initialization hooks, etc. if all else were to fail, nothing stops one from going back to 'basic' SQL for some things.
      I think I didn't properly state my question. Let's say I want to add business logic to the module, say a login() method. This method would take some input and then set/clear columns as appropriate such that a user is now logged in. It might even call methods in other modules. So constraints, triggers, etc would not accomplish this.

      I assume others are doing the same.

        that's application logic, in my mind, and not data logic ...

        that's not the goal of Class::DBI. you can do that same get/set operation at the app level, and good MVC would say that you don't do it at the data level.

Re^3: Class::DBI -- does it get any easier?
by davorg (Chancellor) on Nov 15, 2004 at 09:26 UTC

    Yes. I often have packages that look something like this:

    use Class::DBI::Loader; my $loader = Class::DBI::Loader->new( dsn => 'dbi:mysql:dbname', user => 'user', password => 'p455w0rd', namespace => 'MyApp', ); # MyObject is one of the tables in the database package MyApp::MyObject; # define various methods on that class 1;
    --
    <http://www.dave.org.uk>

    "The first rule of Perl club is you do not talk about Perl club."
    -- Chip Salzenberg

Log In?
Username:
Password:

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

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

    No recent polls found