php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #56617 execute converts type of given array to string
Submitted: 2005-10-28 07:47 UTC Modified: 2005-10-28 23:01 UTC
From: bmansion at mamasam dot com Assigned: wez (profile)
Status: Closed Package: PDO (PECL)
PHP Version: 5_1 CVS-2005-10-28 (dev) OS: Mac OS X 10.4
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: bmansion at mamasam dot com
New email:
PHP Version: OS:

 

 [2005-10-28 07:47 UTC] bmansion at mamasam dot com
Description:
------------
Actually, the version is PHP Version 5.1.0RC2-dev compiled on Oct 1 2005

When given an array containing an integer, pdo->execute() will convert the type to a string.


Reproduce code:
---------------
<?php
/*CREATE TABLE book (
  id int(11) NOT NULL,
  PRIMARY KEY  (id)
); INSERT INTO book VALUES (1);*/

$pdo = new PDO('mysql:dbname=bookstore;host=localhost', 'bookstore', 'password');
$values = array(1);
var_dump($values);
$stmt = $pdo->prepare('SELECT * FROM book WHERE id = ?');
$stmt->execute($values);
var_dump($values);
?>

Expected result:
----------------
array(1) {
  [0]=>
  int(1)
}
array(1) {
  [0]=>
  int(1)
}


Actual result:
--------------
array(1) {
  [0]=>
  int(1)
}
array(1) {
  [0]=>
  string(1) "1"
}

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-10-28 09:56 UTC] wez@php.net
Expected behaviour; the default fetch is (usually) a string.
You are responsible for juggling it into different types, as per the usual PHP type juggling.
 [2005-10-28 10:20 UTC] bmansion at mamasam dot com
The bug is not about values being returned, it is about values used as parameters being modified for no reason, as if $values was used by reference by execute().

Am I missing something or is it you ?
 [2005-10-28 23:01 UTC] wez@php.net
This bug has been fixed in CVS.

In case this was a documentation problem, the fix will show up at the
end of next Sunday (CET) on pecl.php.net.

In case this was a pecl.php.net website problem, the change will show
up on the website in short time.
 
Thank you for the report, and for helping us make PECL better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Oct 31 23:01:28 2024 UTC