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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Wed May 29 10:01:32 2024 UTC