Re: SQL Generation ( was Re: prefixing table names?)

[prev] [thread] [next] [Date index for 2004/10/19]

From: merlyn (Randal L. Schwartz)
Subject: Re: SQL Generation ( was Re: prefixing table names?)
Date: 10:00 on 19 Oct 2004
>>>>> "Randal" == Randal L Schwartz <merlyn@xxxxxxxxxx.xxx> writes:

Randal> package Class::DBI::mysql;

Randal> sub _do_search {
Randal>   for ($_[-1]) { # alias for easy access
Randal>     if (ref $_ eq "HASH") {
Randal>       if (defined(my $limit = $_->{limit})) {
Randal>         $_->{order_by} .= " LIMIT $limit";
Randal>         delete $_->{limit};
Randal>       }
Randal>     }
Randal>   }
Randal>   goto &{$class->can("SUPER::_do_search")};
Randal> }

Actually, no reason to compute that last goto dynamically.  Slight
optimization:

    my $SUPER_do_search = __PACKAGE__->can("SUPER::_do_search") or die;

    sub _do_search {
      ...
      goto &$SUPER_do_search;
    }

And to do this "cleaner", change _do_search so that it accepts

        { order_by => "foo", extra => "bar" }

and just inserts "bar" literally out there.  Then, derived classes
can do something like the above, then massage it into "extra".

        -- 
        Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@xxxxxxxxxx.xxx> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

(message missing)

prefixing table names?
bowen 15:20 on 15 Oct 2004

Re: prefixing table names?
jason 15:36 on 15 Oct 2004

Re: prefixing table names?
Tony Bowden 18:45 on 15 Oct 2004

SQL Generation ( was Re: prefixing table names?)
jason scott gessner 00:08 on 19 Oct 2004

Re: SQL Generation ( was Re: prefixing table names?)
merlyn (Randal L. Schwartz) 09:46 on 19 Oct 2004

Re: SQL Generation ( was Re: prefixing table names?)
merlyn (Randal L. Schwartz) 10:00 on 19 Oct 2004

Re: prefixing table names?
Tony Bowden 15:36 on 15 Oct 2004

Re: prefixing table names?
Bowen Dwelle 22:05 on 15 Oct 2004

Re: prefixing table names?
Bradley K. Embree 22:16 on 15 Oct 2004

Re: prefixing table names?
Bowen Dwelle 22:48 on 15 Oct 2004

Re: prefixing table names?
Bowen Dwelle 23:20 on 15 Oct 2004

Re: prefixing table names?
Perrin Harkins 16:44 on 15 Oct 2004

FromCGI and Untaint question
Peter Speltz 17:23 on 19 Oct 2004

Re: prefixing table names?
Bowen Dwelle 01:31 on 02 Nov 2004

Re: prefixing table names?
Bowen Dwelle 16:36 on 02 Nov 2004

Generated at 11:35 on 01 Dec 2004 by mariachi v0.52