rlb3 has asked for the wisdom of the Perl Monks concerning the following question:
Hello Monks,
I'm having some trouble building an SQL statement from a
web form. I'm using Class::DBI's set_sql method to create and new method
that changes everytime through a loop.
I 'm not sure why the table names in the where statement are not changing.
rlb3
I'm having some trouble building an SQL statement from a
web form. I'm using Class::DBI's set_sql method to create and new method
that changes everytime through a loop.
A full SQL statement would look like this:my $tables = [ qw/ starting_point_topics related_topics other_topics / + ]; my $results = {}; foreach my $table (@{$tables}) { my $query = qq{ SELECT res.* FROM res,$table,topics WHERE $query_t +emp ORDER BY `rank` DESC }; Library::Data::Res->set_sql(full_text => $query); $results->{$table} = Library::Data::Res->search_full_text; }
The starting_point_topics would change as it loops and WHERE statement will change also but this is the one i'm testing right now. The error i'm getting is:SELECT res.* FROM res,starting_point_topics,topics WHERE ((starting_point_topics.res = res.id) AND (starting_point_topics.topic = topics.id) AND (topics.name LIKE '%'))
search_full_text() already exists at /data/web/perl/lib/Library/Result +s.pm line 95 ORDER BY `rank` DESC SELECT res.* FRO +M res,related_topics,topics WHERE ((starting_point_topics.res = +res.id) AND (starting_point_topics.topic = + topics.id) AND (topics.name LIKE '%')) AND ((related_topics.res = res.id) AND (related_topics.topic = topics +.id) AND (topics.name LIKE '%'))
I 'm not sure why the table names in the where statement are not changing.
rlb3
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: How do I build a SQL statements in Class::DBI programmatically
by perrin (Chancellor) on Dec 08, 2004 at 22:31 UTC | |
by saberworks (Curate) on Dec 08, 2004 at 23:11 UTC | |
by perrin (Chancellor) on Dec 08, 2004 at 23:22 UTC |
Back to
Seekers of Perl Wisdom