List:Commits« Previous MessageNext Message »
From:uwendel Date:April 8 2008 10:09am
Subject:PHP mysqlnd svn commit: r1401 - trunk/tests/ext/pdo_mysql
View as plain text  
Author: uwendel
Date: 2008-04-08 12:09:14 +0200 (Tue, 08 Apr 2008)
New Revision: 1401

Added:
   trunk/tests/ext/pdo_mysql/pdo_mysql_subclass.phpt
Log:
See also http://bugs.php.net/bug.php?id=44425


Added: trunk/tests/ext/pdo_mysql/pdo_mysql_subclass.phpt
===================================================================
--- trunk/tests/ext/pdo_mysql/pdo_mysql_subclass.phpt	                        (rev 0)
+++ trunk/tests/ext/pdo_mysql/pdo_mysql_subclass.phpt	2008-04-08 10:09:14 UTC (rev 1401)
@@ -0,0 +1,98 @@
+--TEST--
+MySQL PDOStatement->execute()/fetch(), Non-SELECT
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+require_once('mysql_pdo_test.inc');
+MySQLPDOTest::skip();
+if (version_compare(PHP_VERSION, '5.0.0', '<'))
+	die("skip Requires PHP 5.0+");
+?>
+--FILE--
+<?php
+	require_once('mysql_pdo_test.inc');
+
+	// No silly strict mode warnings, please!
+	error_reporting(E_ALL^E_STRICT);
+	ini_set('display_errors', false);
+
+	try {
+
+		class MyPDO extends PDO {
+
+			public function __construct() {
+				$this->protocol();
+				return call_user_func_array(array($this, 'parent::__construct'), func_get_args());
+			}
+
+			public function exec() {
+				$this->protocol();
+				return call_user_func_array(array($this, 'parent::exec'), func_get_args());
+			}
+
+			public function query() {
+				$this->protocol();
+				return call_user_func_array(array($this, 'parent::query'), func_get_args());
+			}
+
+			public function __call($method, $args) {
+				$this->protocol();
+			}
+
+			private function protocol() {
+				$stack = debug_backtrace();
+				if (!isset($stack[1]))
+					return;
+
+				printf("%s(", $stack[1]['function']);
+				$args = '';
+				foreach ($stack[1]['args'] as $k => $v)
+					$args .= sprintf("%s, ", var_export($v, true));
+				if ($args != '')
+					printf("%s", substr($args, 0, -2));
+				printf(")\n");
+			}
+
+		}
+
+		$db = new MyPDO(PDO_MYSQL_TEST_DSN, PDO_MYSQL_TEST_USER, PDO_MYSQL_TEST_PASS);
+		$db->exec('DROP TABLE IF EXISTS test');
+		$db->exec('CREATE TABLE test(id INT)');
+		$db->exec('INSERT INTO test(id) VALUES (1), (2)');
+		$stmt = $db->query('SELECT * FROM test ORDER BY id ASC');
+		var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
+		var_dump($stmt->fetch());
+		$db->intercept_call();
+
+
+	} catch (PDOException $e) {
+		printf("[001] %s [%s] %s\n",
+			$e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo()));
+	}
+
+	$db->exec('DROP TABLE IF EXISTS test');
+	print "done!\n";
+?>
+--EXPECTF--
+__construct('%s', '%s', '%s')
+exec('DROP TABLE IF EXISTS test')
+exec('CREATE TABLE test(id INT)')
+exec('INSERT INTO test(id) VALUES (1), (2)')
+query('SELECT * FROM test ORDER BY id ASC')
+array(2) {
+  [0]=>
+  array(1) {
+    ["id"]=>
+    string(1) "1"
+  }
+  [1]=>
+  array(1) {
+    ["id"]=>
+    string(1) "2"
+  }
+}
+bool(false)
+__call('intercept_call', array (
+))
+exec('DROP TABLE IF EXISTS test')
+done!
\ No newline at end of file

Thread
PHP mysqlnd svn commit: r1401 - trunk/tests/ext/pdo_mysqluwendel8 Apr