Hello, I'm getting a SQL error when using Class::DBI, and it's pretty baffling to me. I can't tell if I'm doing something wrong, or if I am missing a dependency or what is up. Here's the error,
FS::Model::Items can't SELECT FROM items WHERE address = ? AND zip = ? : DBD::mysql::st execute failed: You have an error in your SQL syntax; + check the manual that corresponds to your MySQL server version for t +he right syntax to use near 'FROM items WHERE address = '170 W. 15th St.' AND zip = '10011'' at line 2 [for S +tatement "SELECT FROM items WHERE address = ? AND zip = ? " with ParamValues: 0='170 W. 15th St.', 1='10011'] at /Library/Perl/5 +.8.8/DBIx/ContextualFetch.pm line 52. at /Library/Perl/5.8.8/Class/DBI/Search/Basic.pm line 169
Here's how i define the table in the objects initialization...
# within FS::Model::Items->new(); $self->table('items'); $self->columns( qw/item item_type name lng lat zip url phone fax address/ );
And then this is the line from the object method that generates the error...
# within FS::Model::Items->get_info my $item = $self->search( address => $item_info->{address}, zip => $item_info->{zip}, );
It all comes together with something like this...
my $item_obj = FS::Model::Items->new(); my $res_obj = $item_obj->get_info($item_info);
The Items object is an InsideOut object which it inherits from my DBI Module which inherits from Class::DBI; So...
package FS::Model::Items; use Object::InsideOut qw(FS::Model::DBI);
and then...
package FS::Model::DBI; use base ( Class::DBI ); use Object::InsideOut;
I'm running on OS X 10.5. From the error, it seems like Class::DBI isn't trying to select any columns...but I really can't understand why. Any ideas? Thanks.

In reply to Class::DBI weirdness sql error by vansance

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.