On Wed, 06 Jun 2001 20:32:07 -0700, Trevor Schellhorn wrote:
>$statement = q{
> SELECT *
> FROM table
> WHERE field1 = ?
> AND field2 = ?
>ORDER BY fieldname
> LIMIT ?
> , ?
>};
...
>When the '$offset' is changed to 30, I get the error:
>
>DBD::mysql::db selectall_arrayref failed: You have an error in your SQL
>syntax near ''30'
> , 30' at line xx
That looks vaguely familiar. Nowhere you tell the database that some of
your placeholders are containing numbers. In my experience, DBI always
falls back to interpreting them as strings.
>Is there a way to tell it to NOT quote that number?
Indeed. You need to tell the statement handle, i.e. the result of the
prepare method, which placeholders represent numbers. One way to do
that, is:
$sth = $dbh->prepare($statement);
$sth->bind_param(3, undef, SQL_INTEGER);
which says that the third placeholder represents a number. Now, you can
go ahead and do your business.
--
Bart.