|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-02-26 10:45 UTC] wez@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 08:00:02 2025 UTC |
Description: ------------ For emulated MySQL prepared queries; everything gets treated as a string: 10:25 <@_Wez_> the emulation stuff forces the input to be a string 10:25 <@_Wez_> and then quotes it S Reproduce code: --------------- <?php function pretty_pdo_error($PDO) { $err = $PDO->errorInfo(); echo "PDO Error: {$err[1]}: {$err[2]}\n"; } try { $PDO = new PDO('mysql:dbname=testdb;host=localhost', 'testdb', 'testdb'); } catch (PDOException $e) { echo 'Connection failed: ' . $e->getMessage(); die(); } $sql = "SELECT * FROM testtable LIMIT :limit"; $QS = $PDO->prepare($sql); $limit = 10; $QS->bindParam(':limit', $limit, PDO_PARAM_INT); if (FALSE === $QS->execute()) { pretty_pdo_error($PDO); } ?> Expected result: ---------------- no error Actual result: -------------- PDO Error: 1064: You have an error in your SQL syntax near '"10"' at line 1