1--TEST--
2MySQL PDOStatement->execute()/fetch(), Non-SELECT
3--SKIPIF--
4<?php
5require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'skipif.inc');
6require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
7MySQLPDOTest::skip();
8?>
9--FILE--
10<?php
11	require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
12
13	// No silly strict mode warnings, please!
14	error_reporting(E_ALL^E_STRICT);
15	ini_set('display_errors', false);
16
17	try {
18
19		class MyPDO extends PDO {
20
21			public function __construct() {
22				$this->protocol();
23				return call_user_func_array(array($this, 'parent::__construct'), func_get_args());
24			}
25
26			public function exec() {
27				$this->protocol();
28				return call_user_func_array(array($this, 'parent::exec'), func_get_args());
29			}
30
31			public function query() {
32				$this->protocol();
33				return call_user_func_array(array($this, 'parent::query'), func_get_args());
34			}
35
36			public function __call($method, $args) {
37				print "__call(".var_export($method,true).", ".var_export($args, true).")\n";
38				// $this->protocol();
39			}
40
41			private function protocol() {
42				$stack = debug_backtrace();
43				if (!isset($stack[1]))
44					return;
45
46				printf("%s(", $stack[1]['function']);
47				$args = '';
48				foreach ($stack[1]['args'] as $k => $v)
49					$args .= sprintf("%s, ", var_export($v, true));
50				if ($args != '')
51					printf("%s", substr($args, 0, -2));
52				printf(")\n");
53			}
54
55		}
56
57		$db = new MyPDO(PDO_MYSQL_TEST_DSN, PDO_MYSQL_TEST_USER, PDO_MYSQL_TEST_PASS);
58		$db->exec('DROP TABLE IF EXISTS test');
59		$db->exec('CREATE TABLE test(id INT)');
60		$db->exec('INSERT INTO test(id) VALUES (1), (2)');
61		$stmt = $db->query('SELECT * FROM test ORDER BY id ASC');
62		var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
63		var_dump($stmt->fetch());
64		$db->intercept_call();
65
66
67	} catch (PDOException $e) {
68		printf("[001] %s [%s] %s\n",
69			$e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo()));
70	}
71
72	$db->exec('DROP TABLE IF EXISTS test');
73	print "done!\n";
74?>
75--CLEAN--
76<?php
77require dirname(__FILE__) . '/mysql_pdo_test.inc';
78$db = MySQLPDOTest::factory();
79$db->exec('DROP TABLE IF EXISTS test');
80?>
81--EXPECTF--
82__construct('%S', '%S', %s)
83exec('DROP TABLE IF EXISTS test')
84exec('CREATE TABLE test(id INT)')
85exec('INSERT INTO test(id) VALUES (1), (2)')
86query('SELECT * FROM test ORDER BY id ASC')
87array(2) {
88  [0]=>
89  array(1) {
90    ["id"]=>
91    string(1) "1"
92  }
93  [1]=>
94  array(1) {
95    ["id"]=>
96    string(1) "2"
97  }
98}
99bool(false)
100__call('intercept_call', array (
101))
102exec('DROP TABLE IF EXISTS test')
103done!
104