Re: Removing auto-generated methods (set_sql)

[prev] [thread] [next] [Date index for 2004/06/14]

From: Perrin Harkins
Subject: Re: Removing auto-generated methods (set_sql)
Date: 17:30 on 14 Jun 2004
On Mon, 2004-06-14 at 12:57, William McKee wrote:
> My script is being run in a mod_perl environment. I need to dynamically
> generate a search based on input to a web form. This search requires a
> join so I can't use standard CDBI methods. The WHERE clause could change
> from call to call thus I regenerate it using SQL::Abstract.

Either give each search a unique name (by joining the searched fields or
something) or do something like this:

    my $dbh = $self->db_Main();
    my $sth = $dbh->prepare_cached(
        some_sub_that_generates_your_sql()
    );

    $sth->execute(@params);
    my @results = $self->sth_to_objects($sth);

> See above. However, it seems like CDBI should allow a means to remove a
> method if it is going to carp about redefining one.

It's not CDBI, it's Perl.  The set_sql method creates a sub based on the
name you give it.  Perl will complain if you redefine a subroutine,
which is what you are doing when you call set_sql twice with the same
name.  You could turn that warning off, but you really should not be
doing it this way.

- Perrin

(message missing)

Removing auto-generated methods (set_sql)
William McKee 16:27 on 14 Jun 2004

Re: Removing auto-generated methods (set_sql)
Tony Bowden 16:33 on 14 Jun 2004

Re: Removing auto-generated methods (set_sql)
William McKee 16:57 on 14 Jun 2004

Re: Removing auto-generated methods (set_sql)
Perrin Harkins 17:30 on 14 Jun 2004

Re: Removing auto-generated methods (set_sql)
William McKee 20:51 on 14 Jun 2004

Re: Removing auto-generated methods (set_sql)
Perrin Harkins 20:56 on 14 Jun 2004

Re: Removing auto-generated methods (set_sql)
William McKee 21:48 on 14 Jun 2004

Re: Removing auto-generated methods (set_sql)
Tony Bowden 21:59 on 14 Jun 2004

Re: Removing auto-generated methods (set_sql)
Tony Bowden 08:53 on 15 Jun 2004

Re: Removing auto-generated methods (set_sql)
William McKee 17:53 on 15 Jun 2004

Re: Removing auto-generated methods (set_sql)
Tony Bowden 19:59 on 15 Jun 2004

Re: Removing auto-generated methods (set_sql)
Perrin Harkins 00:04 on 16 Jun 2004

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