#46514 [NEW]: PDO::prepare quoting replacement variables produces undesired results

From: Date: Fri, 07 Nov 2008 06:01:30 +0000
Subject: #46514 [NEW]: PDO::prepare quoting replacement variables produces undesired results
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-130738@lists.php.net to get a copy of this message
From: jrconlin at yahoo dot com Operating system: Linux PHP version: 5.2.6 PHP Bug Type: MySQL related Bug description: PDO::prepare quoting replacement variables produces undesired results Description: ------------ using PDO->prepare if I create a string like 'select * from foo match (column) against (":var");' and then call execute(array(":var"=>"value"); I get a select that does not get the :var replaced. If I move the quotes to the variable string: e.g. 'select * from foo match (column) against (:var);' and then call execute(array(":var"=>"\"value\""); it works fine. Reproduce code: --------------- global $pdo,$mRequest; //$mRequest = $pdo->prepare($movieQuery); if (!$mRequest) { $mRequest = $pdo->prepare('select ":title",nflx_data.movieid,nflx_data.url,match (title) against (":title") as rank from nflx_data where match (title) against (":title") order by rank desc limit 1'); } $mRequest->execute(Array(':title'=>$title)); $result = $mRequest->fetch(PDO::FETCH_ASSOC); $mRequest->closeCursor(); print_r($result); Expected result: ---------------- I expect to get different results based on the value of $title being inserted at each instance of :title. Actual result: -------------- Array ( [movieid] => 20557937 [:title] => :title [url] => ... ) -- Edit bug report at http://bugs.php.net/?id=46514&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=46514&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=46514&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=46514&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=46514&r=fixedcvs Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=46514&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=46514&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=46514&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=46514&r=needscript Try newer version: http://bugs.php.net/fix.php?id=46514&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=46514&r=support Expected behavior: http://bugs.php.net/fix.php?id=46514&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=46514&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=46514&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=46514&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=46514&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=46514&r=dst IIS Stability: http://bugs.php.net/fix.php?id=46514&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=46514&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=46514&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=46514&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=46514&r=mysqlcfg

« previous php.bugs (#130738) next »