LIMIT with placeholder
[prev]
[thread]
[next]
[Date index for 2004/06/10]
I am probably missing something obvious here, but could not make this
work.
The following works fine:
In the table
__PACKAGE__->set_sql(latest => "SELECT * FROM __TABLE__ LIMIT 10");
the user:
My::Names->search_latest();
but I cannot convince it to take a palace holder instead of the hard
coded 10.
In the table
__PACKAGE__->set_sql(latest => "SELECT * FROM __TABLE__ LIMIT %s");
the user:
My::Names->search_latest(10);
I get this:
My::Names can't SELECT * FROM posts LIMIT : DBD::SQLite::st execute failed: called
with 1 bind variables when 0 are needed [for Statement "SELECT * FROM
names LIMIT "] at /opt/perl584/lib/site_perl/5.8.4/DBIx/ContextualFetch.pm
Replacing %s by ?
__PACKAGE__->set_sql(latest => "SELECT * FROM __TABLE__ LIMIT ?");
I get this:
My::Names can't SELECT * FROM posts LIMIT ?: DBD::SQLite::st
execute failed: near "'10'": syntax error [for Statement "SELECT * FROM
names LIMIT ?"] at
/opt/perl584/lib/site_perl/5.8.4/DBIx/ContextualFetch.pm line 51.
BTW it is not clear (to me) from the documentation if the placeholder
should be %s or ?.
All this with CDBI 0.96 and SQLite
Gabor
|
LIMIT with placeholder
Gabor Szabo 02:47 on 10 Jun 2004
|