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.
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;
}
A full SQL statement would look like this:
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 '%'))
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:
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
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.