Hello Monks, For the last few projects I have be using Class::DBI, Template Toolkit, and CGI::Application to build my web apps. Today was the first time I have tried to use Class::DBI::AbstractSearch, and it seems to be giving me trouble. Ok I’m going to get donw to it and show some code:
package Library::Data::Base; use strict; use warnings; use Class::DBI::AbstractSearch; use base qw(Class::DBI::Pg); __PACKAGE__->set_db(Main => 'dbi:Pg:dbname=library;host=10.0.0.1, ‘user’, ‘pass’,{AutoCommit + => 1}); package Library::Data::Res; use strict; use warnings; use base qw( Library::Data::Base ); __PACKAGE__->set_up_table('res'); package WebApp; use strict; use warnings; use Library::Data::Res; my @results = Library::Data::Res->search_where( information_type => \@info +_type, format => \@form +ats, starting_point => \@topi +cs );
I get theses errors:
[Tue Apr 6 15:46:33 2004] [error] Library::Data::ResLibrary::Data::Re +s can't SELECT id FROM res WHERE ( ( ( format = ? ) ) AND AND ( ( starting_point = ? ) ) ) : DBD::Pg::st execute failed: ERROR: syntax error at or near "AND" at character 126 [for Statement "SELECT id FROM res WHERE ( ( ( format = ? ) ) AND AND ( ( starting_point = ? + ) ) ) "] at /usr/lib/perl5/site_perl/5.8.1/Ima/DBI.pm line 714. errDBD::Pg::st execute failed: ERROR: syntax error at or near "AND" a +t character 126 [for Statement "SELECT id FROM res WHERE ( ( ( format = ? ) ) AND AND ( ( starting_point = ? + ) ) ) "] at /usr/lib/perl5/site_perl/5.8.1/Ima/DBI.pm line 714. at /usr/lib/perl5/site_perl/5.8.3/Class/DBI/AbstractSearch.pm line 26
I’m not exactly sure what I’m seeing here. It looks as if either its adding an extra AND or its leaving out one of the fields it should be searching on. This is the first time I’m trying to use Class::DBI::AbstractSearch so I could be doing something very wrong. Anyway, thanks for the help.

rlb3

Update: \@info_type,\@formats,\@topics are from a web form. I have tested it to check to see if data is getting in. it is.

In reply to Problems with Class::DBI::AbstractSearch by rlb3

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.