1--TEST-- 2PDO Common: Bug #52098 Own PDOStatement implementation ignore __call() 3--SKIPIF-- 4<?php 5if (!extension_loaded('pdo')) die('skip'); 6$dir = getenv('REDIR_TEST_DIR'); 7if (false == $dir) die('skip no driver'); 8require_once $dir . 'pdo_test.inc'; 9PDOTest::skip(); 10?> 11--FILE-- 12<?php 13if (getenv('REDIR_TEST_DIR') === false) putenv('REDIR_TEST_DIR='.__DIR__ . '/../../pdo/tests/'); 14require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc'; 15$db = PDOTest::factory(); 16 17@$db->exec("DROP TABLE test"); 18$db->exec("CREATE TABLE test (x int)"); 19$db->exec("INSERT INTO test VALUES (1)"); 20 21class MyStatement extends PDOStatement 22{ 23 public function __call($name, $arguments) 24 { 25 echo "Calling object method '$name'" . implode(', ', $arguments). "\n"; 26 } 27} 28/* 29Test prepared statement with PDOStatement class. 30*/ 31$derived = $db->prepare('SELECT * FROM test', array(PDO::ATTR_STATEMENT_CLASS=>array('MyStatement'))); 32$derived->execute(); 33$derived->foo(); 34$derived->fetchAll(); 35$derived = null; 36 37/* 38Test regular statement with PDOStatement class. 39*/ 40$db->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('MyStatement')); 41$r = $db->query('SELECT * FROM test'); 42echo $r->bar(); 43$r->fetchAll(); 44$r = null; 45 46/* 47Test object instance of PDOStatement class. 48*/ 49$obj = new MyStatement; 50echo $obj->lucky(); 51 52$db->exec("DROP TABLE test"); 53?> 54--EXPECT-- 55Calling object method 'foo' 56Calling object method 'bar' 57Calling object method 'lucky' 58