php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42598 Bound parameter values cause no results for fetchAll()
Submitted: 2007-09-08 17:14 UTC Modified: 2007-09-16 01:00 UTC
From: tobias382 at gmail dot com Assigned: sixd (profile)
Status: No Feedback Package: PDO related
PHP Version: 5.2.4 OS: Windows XP SP2
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: tobias382 at gmail dot com
New email:
PHP Version: OS:

 

 [2007-09-08 17:14 UTC] tobias382 at gmail dot com
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
        )
)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-09-08 18:46 UTC] tobias382 at gmail dot com
Replicating this test within a SQLite environment yields the expected results, so it's possible that the problem is with the PDO_OCI driver.
 [2007-09-08 22:36 UTC] sixd@php.net
Not enough information was provided for us to be able
to handle this bug. Please re-read the instructions at
http://bugs.php.net/how-to-report.php

If you can provide more information, feel free to add it
to this bug and change the status back to "Open".

Thank you for your interest in PHP.


I can't reproduce this.  The script

<?php
  $db = new PDO('oci:dbname=ca-tools1/XE', 'hr', 'hrpwd');
  $stmt = $db->prepare("select city from locations where country_id = :c");
  $id = "UK";
  $stmt->bindParam(":c", $id, PDO::PARAM_STR);
  $stmt->execute();
  print_r($stmt->fetchAll());
?>

gives the expected:

Array
(
    [0] => Array
	(
		[CITY] => London
		[0] => London
	 )

    [1] => Array
	(
		[CITY] => Oxford
		[0] => Oxford
	 )

    [2] => Array
	(
		[CITY] => Stretford
		[0] => Stretford
	 )

 )

Can you examine the data & SQL and identity what does and doesn't work?
 [2007-09-16 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: Thu Jul 17 01:01:33 2025 UTC