Re: search_"method" for custom queries...

[prev] [thread] [next] [Date index for 2004/12/11]

From: William McKee
Subject: Re: search_"method" for custom queries...
Date: 19:32 on 11 Dec 2004
On Sat, Dec 11, 2004 at 08:24:40AM -0600, Michael Jensen wrote:
> I have a few places on my site that I use some actual full sentence SQL 
> using the search_namedmethod thing. I have this code directly in my 
> pages right now (so not in my package). It gets called 20 times on the 
> same page, with a different query for each row. I was looking over my 
> HTTPD error log and noticed a ton of entries like this:

I've seen these types of errors when I use the set_sql method to create
custom SQL statements. If this is what you are doing, then take a look
at the recipe on the wiki which shows a way to create a statement that
can contain dynamic where clauses[1]. Although it's about creating
joins, it would apply to any situation where you need to create custom
SQL that can have alternative where clauses.

BTW, there's another module for creating dynamic SQL called
SQL::Interpolate which you may want to check out. It's not on CPAN yet
but Mark Stosberg has good things to say about it[2]. Like
SQL::Abstract, though, it doesn't support dynamic joins.


> Is there an easier or more appropriate way for doing this? It sounds 
> like CDBI only likes one of these (per name). Should I make the name 
> dynamic by using a unique ID?

I'd think that you'll see better performance if you create a single sql
statement that can take dynamic where clauses rather than a bunch of sql
static statements.


William

[1] http://www.class-dbi.com/cgi-bin/wiki/index.cgi?UsingJoins
[2] http://use.perl.org/~markjugg/journal/22115

        -- 
        Knowmad Services Inc.
http://www.knowmad.com

search_"method" for custom queries...
Michael Jensen 14:24 on 11 Dec 2004

Re: search_"method" for custom queries...
William McKee 19:32 on 11 Dec 2004

Generated at 01:36 on 13 Dec 2004 by mariachi v0.52