#44425 [Csd->Opn]: Extending PDO/MySQL class with a __call() function doesn't work
ID: 44425
User updated by: phpbugs at wayoverthere dot com
Reported By: phpbugs at wayoverthere dot com
-Status: Closed
+Status: Open
Bug Type: PDO related
-Operating System: Linux
+Operating System: Linux/Windows
PHP Version: 5.2CVS-2008-03-13 (snap)
New Comment:
I'm still seeing the problem. I have recompiled PHP
(php5.3-200803131930) on several different boxes - all Linux, but
different distros (Ubuntu 7.10, openSuse 10.2, and a very old Gentoo
box). On a hunch, I uninstalled the system PHP, thinking the custom
PHP was using the system .so's. Same thing.
I even tried installing PHP on a Win2k box using the snapshot
http://snaps.php.net/win32/php5.3-win32-200803132030.zip.
I used the
recommended php.ini file as a base config file, but enabled
php_pdo.dll, php_pdo_mysql.dll, and php_pdo_sqlite.dll extensions.
Then I created test.php and put this in it:
<?php
class test extends PDO {
function __call($name, array $args) {
echo "Called $name in ".__CLASS__.'<br>';
}
function foo() {
echo "Called foo in ".__CLASS__.'<br>';
}
}
$sqlite = new test('sqlite::memory:');
$sqlite->foo();
$sqlite->bar();
$mysql = new test('mysql:dbname=foo;host=10.1.1.142','foo','bar');
$mysql->foo();
$mysql->bar();
?>
Running "php test.php" gives:
Called foo in test<br>Called bar in test<br>Called foo in
test<br>Fatal error: Call to undefined method test::bar() in C:
\php5\test.php on line 17
Previous Comments:
------------------------------------------------------------------------
[2008-03-13 16:10:44] iliaa@php.net
Works fine in snapshot and PHP 5.3
------------------------------------------------------------------------
[2008-03-13 04:52:06] phpbugs at wayoverthere dot com
Description:
------------
Exact(?) same bug as #43663, except connecting to a MySQL 5 server. I
have also tried a 5.3 snapshot & got the same result. Tried both cgi
and cli.
Reproduce code:
---------------
<?php
class test extends PDO {
function __call($name, array $args) {
echo "Called $name in ".__CLASS__.'<br>';
}
function foo() {
echo "Called foo in ".__CLASS__.'<br>';
}
}
$a = new test('mysql:dbname=test;host=localhost','user','pw');
$a->foo();
$a->bar();
?>
Expected result:
----------------
"Called foo in test
Called bar in test"
Actual result:
--------------
"Called foo in test
Fatal error: Call to undefined method test::bar() in call.php on
line 24"
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=44425&edit=1
Thread (7 messages)