[Catalyst] ActiveRecord for Perl

John Goulah jgoulah at gmail.com
Tue May 22 16:52:22 GMT 2007


I agree with you, using DBIx for simple stuff is fine, but after a while raw
SQL is sometimes nice to have.

I cant figure out how to return the data in object form, but this will at
least give you some data:

__PACKAGE__->load_components(qw/
        ResultSetManager
        PK::Auto
        Core
        /);

sub get_data : ResultSet {
    my ($self) =3D @_;
    my $dbh =3D $self->result_source->schema->storage->dbh;

    ## use the handle, return data
}

http://search.cpan.org/~JROBINSON/DBIx-Class-0.07005/lib/DBIx/Class/Manual/=
Cookbook.pod#Predefined_searches_without_writing_a_ResultSet_class

But this is not so useful if you cant return it in object form.  (Want to be
able to call functions/associations on that object).  CDBI does it with
sth_to_objects, and there is a CDBI compatibility layer, but I cant seem to
get it working correctly.


John




On 5/22/07, Adam Bartosik <adam.bartosik at hurra.com> wrote:
>
> > What would that achieve that passing literal SQL chunks for SELECT,
> FROM,
> > WHERE etc. wouldn't?
>
> Readability. Complex SQL statements are more clear to understand than
> complex dbix "statements" when you are not an author of DBIX ;)
> I can also test it with simple copy&paste to sql console to see how it
> works, how it is planned / optimized.
>
> I know it is ORM and database abstraction, I'm theoretically independent
> from my DB vendor and so on, but it doesn't change the fact it is more
> complicated, more "noise", more "strange" -opt { qw[col1 col2] } than
> pure SQL statement.
>
> And when all this Catalyst/Dbix stuff is so flexible - why I should
> fight with such approach?
>
> --
> Adam.Bartosik at hurra.com  http://www.hurra-communications.com/
> $ o m e    t e a m  .  d e v e l o p e r
> Hurra Communications, Krakow/Stuttgart/London/Paris/Madrid
>
> _______________________________________________
> List: Catalyst at lists.rawmode.org
> Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
> Searchable archive:
> http://www.mail-archive.com/catalyst@lists.rawmode.org/
> Dev site: http://dev.catalyst.perl.org/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20070522/934c9=
445/attachment-0001.htm


More information about the Catalyst mailing list