Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • There is a UsingJoins [] section on the wiki that is quite good.

    The documentation also has quite a lot about using custom sql and Class::DBI provides things like sth_to_objects which allows you to 'SELECT __ESSENTIAL__ from table_foo a, table_bar b where %s' when used with SQL::Abstract.

    I was working on something like this last night and it works a treat. I was working from Randal's rather handy example.


    @JAPH = qw(Hacker Perl Another Just);
    print reverse @JAPH;
  • package TableOne;
    # set up columns and table here...
    __PACKAGE__->set_sql('by_join' => qq{
    select title, descr
    from table_1, table_2, table_3
    where table_1.pkey=table_2.fkey and date='2004-12-16' and
    table_1.pkey=table_3.fkey and
    field_3 = 'test'});
    # then, in some nearby code:
    my @table_ones = TableOne->search_by_join();

    Using SQL directly is what makes Class::DBI so useful, in my opinion. You always have an escape hatch when you need it.