|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-09-08 18:46 UTC] tobias382 at gmail dot com
[2007-09-08 22:36 UTC] sixd@php.net
[2007-09-16 01:00 UTC] php-bugs at lists dot php dot net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Dec 03 19:00:01 2025 UTC |
Description: ------------ When using any of the various methods of binding parameter values, a query produces no results. When including the parameter value directly in the query string, the query does produce results. Reproduce code: --------------- $db = new PDO('oci://localhost/XE', '------', '-----'); $id = 'Wilson'; $sql = 'SELECT C.* FROM BreadCrumbLinks B, BreadCrumbLinks C WHERE B.Lft BETWEEN C.Lft AND C.Rgt AND B.SiteAreaName = :id ORDER BY C.Lft'; $stmt = $db->prepare($sql); $stmt->bindValue(':id', $id, PDO::PARAM_STR); // Also tried without typecasting and without a colon in the parameter name $stmt->execute(); // also tried with an associative array of parameters and an enumerated array using ? in place of :id in the query print_r($stmt->fetchAll()); $sql = 'SELECT C.* FROM BreadCrumbLinks B, BreadCrumbLinks C WHERE B.Lft BETWEEN C.Lft AND C.Rgt AND B.SiteAreaName = \'' . $id . '\' ORDER BY C.Lft'; $stmt = $db->prepare($sql); $stmt->execute(); print_r($stmt->fetchAll()); Expected result: ---------------- Array ( [0] => Array ( [SITEAREANAME] => Home [0] => Home [SITEAREAURL] => Default.aspx [1] => Default.aspx [LFT] => 1 [2] => 1 [RGT] => 24 [3] => 24 ) ) Array ( [0] => Array ( [SITEAREANAME] => Home [0] => Home [SITEAREAURL] => Default.aspx [1] => Default.aspx [LFT] => 1 [2] => 1 [RGT] => 24 [3] => 24 ) ) Actual result: -------------- Array ( ) Array ( [0] => Array ( [SITEAREANAME] => Home [0] => Home [SITEAREAURL] => Default.aspx [1] => Default.aspx [LFT] => 1 [2] => 1 [RGT] => 24 [3] => 24 ) )