|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-01-15 15:14 UTC] mjs at beebo dot org
[2008-01-15 18:22 UTC] motoma at gmail dot com
[2009-02-13 22:22 UTC] felipe@php.net
[2009-02-21 01:00 UTC] php-bugs at lists dot php dot net
[2009-09-23 21:17 UTC] uw@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Dec 07 18:00:01 2025 UTC |
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"