|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-09-07 22:40 UTC] Roland dot Bouman at interaccess dot nl
[2005-09-07 23:44 UTC] sniper@php.net
[2005-09-08 10:31 UTC] Roland dot Bouman at interaccess dot nl
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 22:00:02 2025 UTC |
Description: ------------ A PDO_MYSQL prepared INSERT statement fails to execute. The driver specific error message reports the value of the variable bound to the parameter as an unknown column. The error message suggests that the actual statement sent to mysql contains a syntax error because of some flaw in the way the parameter value is put into the sql statement No such behaviour is observed in a prepared SELECT statement. An equivalent INSERT statement with the quoted parametervalues hardcoded into the insert does execute as expected. Reproduce code: --------------- <?php $pdo = new PDO('mysql:host','usr','pwd'); $pdo->query('use test'); $pdo->exec('create table tmp( id int auto_increment primary key , flag enum(\'TRUE\',\'FALSE\') , name varchar(10))'); $ins = $pdo->prepare('insert into test.tmp( flag , name) values ( :flag , :name)'); $ins->bindParam(':flag',$flag,PDO_PARAM_STR); $ins->bindParam(':name',$name,PDO_PARAM_STR,20); $flag = 'TRUE'; $name = 'some name'; $ins->execute(); print_r($ins->errorInfo()); --generate output ?> Expected result: ---------------- Array ( [0] => ) or Array ( [0] => 00000 ) indicating successfull execution of the statement at the MySQL server. Actual result: -------------- Array ( [0] => 42S22 [1] => 1054 [2] => Unknown column 'TRUE' in 'field list' )