php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #46514 PDO::prepare quoting replacement variables produces undesired results
Submitted: 2008-11-07 06:01 UTC Modified: 2008-11-15 01:00 UTC
From: jrconlin at yahoo dot com Assigned:
Status: No Feedback Package: PDO related
PHP Version: 5.2.6 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: jrconlin at yahoo dot com
New email:
PHP Version: OS:

 

 [2008-11-07 06:01 UTC] 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] => ... ) 

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-11-07 10:00 UTC] felipe@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/



 [2008-11-15 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri Jul 04 06:01:38 2025 UTC