ID:               43752
 Updated by:       u...@php.net
 Reported By:      motoma at gmail dot com
 Status:           No Feedback
 Bug Type:         PDO related
 Operating System: Windows
 PHP Version:      5.2CVS-2008-01-04 (snap)
 New Comment:

A duplicate of http://bugs.php.net/bug.php?id=41027 ?


Previous Comments:
------------------------------------------------------------------------

[2009-02-21 01:00:00] 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".

------------------------------------------------------------------------

[2009-02-13 22:22:17] fel...@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-01-15 18:22:12] motoma at gmail dot com

I will have to check later.
I doubt that this is the same error, this error is related directly to
the utilization of __toString() in PDO's bindParam() function.

------------------------------------------------------------------------

[2008-01-15 15:14:06] mjs at beebo dot org

Does the mangling happen without the ATTR_PERSISTENT?  It looks like
this may be related to:

http://bugs.php.net/bug.php?id=43831

which concerns $this getting mangled

------------------------------------------------------------------------

[2008-01-04 18:32:58] motoma at gmail dot com

Description:
------------
I built a class with a __toString() member function. When I pass an
instance of this class to bindParam(), the object is overwritten with
the result of __toString().

The result from the code sample suggests that bindParam is overwriting
the value of the object with the object's __toString() value.

Reproduce code:
---------------
<?php
class test
{
        private $a = 1;
        
        public function __toString()
        {
                return strval($this->a);
        }
}

$db = new PDO('mysql:host=localhost;dbname=test', 'root', '',
array(PDO::ATTR_PERSISTENT => true));
$obj = new test();

$prepared = $db->prepare('SELECT * FROM table1 WHERE 1 = :test');

var_dump($obj);
$prepared->bindParam('test', $obj);
var_dump($obj);
?>

Expected result:
----------------
object(test)#2 (1) {
  ["a:private"]=>
  int(1)
}
object(test)#2 (1) {
  ["a:private"]=>
  int(1)
}

Actual result:
--------------
object(test)#2 (1) {
  ["a:private"]=>
  int(1)
}
string(1) "1"


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=43752&edit=1

Reply via email to