#46514 [Opn->Fbk]: PDO::prepare quoting replacement variables produces undesired results
ID: 46514
Updated by: felipe@php.net
Reported By: jrconlin at yahoo dot com
-Status: Open
+Status: Feedback
-Bug Type: MySQL related
+Bug Type: PDO related
Operating System: Linux
PHP Version: 5.2.6
New Comment:
Please try using this CVS snapshot:
http://snaps.php.net/php5.2-latest.tar.gz
For Windows:
http://windows.php.net/snapshots/
Previous Comments:
------------------------------------------------------------------------
[2008-11-07 06:01:30] jrconlin at yahoo dot com
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 this bug report at http://bugs.php.net/?id=46514&edit=1
Thread (2 messages)