Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

I strongly suggest using DBIx::Class.

It learned a lot from the mistakes Class::DBI made and also has a vast amount of features Class::DBI doesn't have.

My favourite is the concept of ResultSets. For example can put together your queries piece by piece:

my $persons = $schema->resultset('Person'); my $active_persons = $person->search({ active => 1 });

Now you can either iterate over the results of those two resultset..

while (my $person = $person->next) { ...; }

.. or get a list of objects, representing rows, back..

my @person_objs = $person->all;

.. or do further searches..

$active_persons->search({ writeup_comment.title => 'Foo', }, { join => { writeup => 'writeup_comment' }, prefetch => 'writeup', }); # gets you all persons with have recieved a comment with the title 'Fo +o' for one of their writeups, for example

.. or do a related_searche to get a resultset associated with another table or view, which are somehow connected to the current resultset:

my $writeups = $active_persons->search_related('Writeup');

Note that SQL statements are only executed when it's actually needed, which makes DBIx::Class quite performant.

Even if DBIx::Class still misses some features one might expect (subqueries, triggers, ...) I think it's already quite stable and I use it for production in several places.

Cheers, Flo


In reply to Re: Class::DBI vs. DBIx::Class by rafl
in thread Class::DBI vs. DBIx::Class by hrr

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • 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, 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, 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others making s'mores by the fire in the courtyard of the Monastery: (14)
    As of 2015-07-06 13:05 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









      Results (74 votes), past polls