pdo parameter in limit?

pdo parameter in limit?

am 15.12.2006 01:53:12 von Patrick Felt

i'm running php "PHP Version 5.1.6-pl6-gentoo" and have run into a bit
of a snag with pdo prepared statements and parameters. we use
parameters in all our queries, but just recently tried to add limits to
some of the queries so we can do paging. when attempting to add a
parameter to the limit section of the sql i get the following error
message and a failed query.

"Warning: PDO::prepare() [function.PDO-prepare
]:
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an
error in your SQL syntax; check the manual that corresponds to your
MySQL server version for the right syntax to use near '? , ?' at line 2 in"

a sample query would be

SELECT * FROM tablename WHERE somecol=1 LIMIT :start, :count

when i remove the :count parameter the error message changes to ".....
near '?' at line 2 in" so i know that the ?, ? map to the two
parameters. i know that there are cases where you can't use parameters
(which don't seem to be clearly documented anywhere), is this one of
them? if not, is there some way to do such a thing or would i just need
to resort to something like mysql_escape_string($start) so that the data
(which comes from users) is properly escaped?

thanks,

pat

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php