php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #57058 Prepared Insert Bug
Submitted: 2006-06-01 18:01 UTC Modified: 2006-10-11 10:56 UTC
From: kfbombar at us dot ibm dot com Assigned:
Status: Closed Package: PDO_ODBC (PECL)
PHP Version: 5_1 CVS-2006-06-01 OS: Windows
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: kfbombar at us dot ibm dot com
New email:
PHP Version: OS:

 

 [2006-06-01 18:01 UTC] kfbombar at us dot ibm dot com
Description:
------------
When testing pdo_odbc on php 5.1.4 with DB2, I got the following test errors when running the standard PDO tests:

PDO Common: PDOStatement iterator [pdo_013.phpt]
PDO Common: PDOStatement SPL iterator [pdo_014.phpt]
PDO Common: PDO::FETCH_INTO [pdo_025.phpt]
PDO Common: extending PDO (2) [pdo_026.phpt]
PDO Common: PDO::FETCH_LAZY [pdo_027.phpt]
PDO Common: extending PDO (3) [pdo_029.phpt]
PDO Common: extending PDO (4) [pdo_030.phpt]

The following error is from pdo_025:

Reproduce code:
---------------
<?php

$db = new PDO("odbc:db2", "db2user", "db2password");

$db->exec('CREATE TABLE test(id INT NOT NULL PRIMARY KEY, val VARCHAR(10), val2 VARCHAR(16))');

$data = array(
  array('10', 'Abc', 'zxy'),
  array('20', 'Def', 'wvu'),
  array('30', 'Ghi', 'tsr'),
  array('40', 'Jkl', 'qpo'),
  array('50', 'Mno', 'nml'),
  array('60', 'Pqr', 'kji'),
);

$stmt = $db->prepare("INSERT INTO test VALUES(?, ?, ?)");
foreach ($data as $row) {
  $stmt->execute($row);
}

class Test {
  public $id, $val, $val2;
}

$stmt = $db->prepare('SELECT * FROM test');
$stmt->setFetchMode(PDO::FETCH_INTO, new Test);
$stmt->execute();

foreach($stmt as $obj) {
  var_dump($obj);
}

echo "===FAIL===\n";

class Fail {
  protected $id;
  public $val, $val2;
}

$stmt->setFetchMode(PDO::FETCH_INTO, new Fail);
$stmt->execute();

foreach($stmt as $obj) {
  var_dump($obj);
}

?>


Expected result:
----------------
object(Test)#%d (3) {
  ["id"]=>
  string(2) "10"
  ["val"]=>
  string(3) "Abc"
  ["val2"]=>
  string(3) "zxy"
}
object(Test)#%d (3) {
  ["id"]=>
  string(2) "20"
  ["val"]=>
  string(3) "Def"
  ["val2"]=>
  string(3) "wvu"
}
object(Test)#%d (3) {
  ["id"]=>
  string(2) "30"
  ["val"]=>
  string(3) "Ghi"
  ["val2"]=>
  string(3) "tsr"
}
object(Test)#%d (3) {
  ["id"]=>
  string(2) "40"
  ["val"]=>
  string(3) "Jkl"
  ["val2"]=>
  string(3) "qpo"
}
object(Test)#%d (3) {
  ["id"]=>
  string(2) "50"
  ["val"]=>
  string(3) "Mno"
  ["val2"]=>
  string(3) "nml"
}
object(Test)#%d (3) {
  ["id"]=>
  string(2) "60"
  ["val"]=>
  string(3) "Pqr"
  ["val2"]=>
  string(3) "kji"
}
===FAIL===

Fatal error: Cannot access protected property Fail::$id in %spdo_025.php on line %d


Actual result:
--------------
object(Test)#2 (3) {
  ["id"]=>
  string(2) "10"
  ["val"]=>
  string(3) "Abc"
  ["val2"]=>
  string(3) "zxy"
}
object(Test)#2 (3) {
  ["id"]=>
  string(2) "20"
  ["val"]=>
  string(3) "Def"
  ["val2"]=>
  string(3) "wvu"
}
object(Test)#2 (3) {
  ["id"]=>
  string(2) "30"
  ["val"]=>
  string(3) "Ghi"
  ["val2"]=>
  string(3) "tsr"
}
object(Test)#2 (3) {
  ["id"]=>
  string(2) "40"
  ["val"]=>
  string(3) "Jkl"
  ["val2"]=>
  string(3) "qpo"
}
object(Test)#2 (3) {
  ["id"]=>
  string(2) "50"
  ["val"]=>
  string(3) "Mno"
  ["val2"]=>
  string(3) "nml"
}
object(Test)#2 (3) {
  ["id"]=>
  string(2) "60"
  ["val"]=>
  string(3) "Pqr"
  ["val2"]=>
  string(3) "kji"
}

Warning: main(): SQLSTATE[]: <<Unknown error>>: 0  (SQLFetchScroll[0] at odbc_stmt.c:363) in pdo_025.php on line 32
===FAIL===

Fatal error: Cannot access protected property Fail::$id in pdo_025.php on line 46


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-10-10 22:24 UTC] wez@php.net
Is this still a problem with the latest PHP 5.2RC ?
(I don't currently have DB2 access to verify this)
 [2006-10-11 10:56 UTC] kfbombar at us dot ibm dot com
Wez,

With the latest PHP 5.2RC, it looks like most of these have been resolved.  So for this bug specifically it can be closed.  Just to let you know, on my end I am seeing two failed tests: bug_38253.phpt and pdo_033.phpt.
Thanks,

Kellen
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 11:01:30 2024 UTC