[CDBI] Use Of Placeholders In set_sql() Example of Beginners Guide

hkclark at gmail.com hkclark at gmail.com
Fri Mar 17 00:19:35 GMT 2006


Hi all,

I'm looking at the set_sql section of the Beginners Guide at:
    http://wiki.class-dbi.com/wiki/Beginners_guide#set_sql

I'm trying to do something like the "...and person.gender = ?" at the
end of that section that they call with:
    my @persons = Music::Artist->search_persons("F");
and it substitutes the "F" for the "?".

However, I can only get any form of substitution to work if use "%s"
in the set_sql() and then do something like this to call it:
    my $sth = Music::Artist->sql_persons("F");
    $sth->execute;
    my @persons = Music::Artist->sth_to_objects($sth);

Any suggestions on what I need to do to get the approach in the
Beginners Guide to work?

Thanks,
H

PS -- When I try to use Beginners Guide approach I get an error
message that looks something like:

DBD::SQLite::db prepare_cached failed: near "person": syntax error(1)
at dbdimp.c line 269 [for Statement "
        select artist.artistid
	from artist, person
	where artist.artistid = person.artistid
	and person.gender = ?
"] at /usr/lib/perl5/site_perl/5.8.5/Ima/DBI.pm line 381.




More information about the ClassDBI mailing list