MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:uwendel Date:January 25 2008 10:11am
Subject:PHP mysqlnd svn commit: r1221 - trunk/tests/ext/pdo_mysql
View as plain text  
Author: uwendel
Date: 2008-01-25 11:11:56 +0100 (Fri, 25 Jan 2008)
New Revision: 1221

Added:
   trunk/tests/ext/pdo_mysql/pdo_mysql_exec_ddl.phpt
Modified:
   trunk/tests/ext/pdo_mysql/TODO_TESTING
Log:
Common DDL statements and PDO::exec()


Modified: trunk/tests/ext/pdo_mysql/TODO_TESTING
===================================================================
--- trunk/tests/ext/pdo_mysql/TODO_TESTING	2008-01-24 18:18:24 UTC (rev 1220)
+++ trunk/tests/ext/pdo_mysql/TODO_TESTING	2008-01-25 10:11:56 UTC (rev 1221)
@@ -16,9 +16,9 @@
 PDO::beginTransaction()                                                --->  90%
 PDO::commit()                                                          ---> 100%
 PDO::__construct                                                       ---> 100%
-PDO::errorCode()                                                       --->  70%
-PDO::errorInfo()                                                       --->  90%
-PDO::exec()                                                            --->  20%
+PDO::errorCode()                                                       ---> 100%
+PDO::errorInfo()                                                       ---> 100%
+PDO::exec()                                                            --->  30%
 PDO::getAttribute()                                                    --->   5%
 PDO::getAvailableDrivers()                                             ---> 100%
 PDO::lastInsertId()                                                    ---> 100%
@@ -99,21 +99,21 @@
   [m] all driver options
 
 
-PDO::errorCode()                                                       --->  70%
+PDO::errorCode()                                                      --->  100%
 
   pdo_errorcode.phpt
   pdo_mysql_errorcode.phpt
 
   [g] invalid paramter
-  [ ] SQLSTATE = 5-anum returned?
+  [m] SQLSTATE = 5-anum returned?
   [g] code on clean line (= code '00000') ?
   [g] code cleaned up after new operation?
-  [] IM code returned?
+  [m] IM code returned?
       [g] match with PDO::errorInfo() --> PDO::errorInfo()
   [m] will two PDOStatement/PDO objects influence each other error codes?
 
 
-PDO::errorInfo()                                                       --->  90%
+PDO::errorInfo()                                                      --->  100%
 
   pdo_errorinfo.phpt
   pdo_mysql_errorinfo.phpt
@@ -122,18 +122,19 @@
   [g] 3-element array returned?
   [g] code on clean line (= code '00000') ?
   [g] info clearned up after new operations?
-  [ ] IM code returned?
+  [m] IM code returned?
   [g] match with PDO::errorCode()
   [m] will two PDOStatement/PDO objects influence each other error codes?
 
 
-PDO::exec()                                                            --->  20%
+PDO::exec()                                                            --->  30%
 
   pdo_exec.phpt
   pdo_mysql_exec.phpt
+  pdo_mysql_exec_ddl.phpt
 
   [g] invalid parameter
-  [ ] all SQL statements
+  [m] most SQL DDL statements
   [m] affected rows: DELETE. INSERT, REPLACE, TRUNCATE, UPDATE, LOAD DATA, LOAD XML
   [ ] single / multiple result set statements
   [g] 0 vs. false

Added: trunk/tests/ext/pdo_mysql/pdo_mysql_exec_ddl.phpt
===================================================================
--- trunk/tests/ext/pdo_mysql/pdo_mysql_exec_ddl.phpt	                        (rev 0)
+++ trunk/tests/ext/pdo_mysql/pdo_mysql_exec_ddl.phpt	2008-01-25 10:11:56 UTC (rev 1221)
@@ -0,0 +1,78 @@
+--TEST--
+MySQL PDO->exec(), affected rows
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+require_once('mysql_pdo_test.inc');
+MySQLPDOTest::skip();
+?>
+--FILE--
+<?php
+	function exec_and_count($offset, &$db, $sql, $exp) {
+
+		try {
+
+			$ret = $db->exec($sql);
+			if ($ret !== $exp) {
+				printf("[%03d] Expecting '%s'/%s got '%s'/%s when running '%s', [%s] %s\n",
+					$offset, $exp, gettype($exp), $ret, gettype($ret), $sql,
+					$db->errorCode(), implode(' ', $db->errorInfo()));
+				return false;
+			}
+
+		} catch (PDOException $e) {
+			printf("[%03d] '%s' has failed, [%s] %s\n",
+				$offset, $sql, $db->errorCode(), implode(' ', $db->errorInfo()));
+			return false;
+		}
+
+		return true;
+	}
+
+	require_once('mysql_pdo_test.inc');
+	$db = MySQLPDOTest::factory();
+	MySQLPDOTest::createTestTable($db,
MySQLPDOTest::detect_transactional_mysql_engine($db));
+
+	/* affected rows related */
+	try {
+
+		exec_and_count(2, $db, 'DROP DATABASE IF EXISTS pdo_exec_ddl', 0);
+		exec_and_count(12, $db, 'DROP DATABASE IF EXISTS pdo_exec_ddl2', 0);
+		if (1 === $db->exec('CREATE DATABASE pdo_exec_ddl')) {
+			// yippie - we can create databases etc.
+			exec_and_count(3, $db, 'ALTER DATABASE pdo_exec_ddl CHARACTER SET latin1', 1);
+			exec_and_count(11, $db, 'RENAME DATABASE pdo_exec_ddl to pdo_exec_ddl2', 0);
+		}
+
+		exec_and_count(4, $db, 'DROP TABLE IF EXISTS pdo_exec_ddl', 0);
+		exec_and_count(5, $db, 'DROP TABLE IF EXISTS pdo_exec_ddl2', 0);
+		if (0 === $db->exec('CREATE TABLE pdo_exec_ddl(id INT, col1 CHAR(2))')) {
+			exec_and_count(5, $db, 'CREATE INDEX idx1 ON pdo_exec_ddl(id)', 0);
+			exec_and_count(6, $db, 'DROP INDEX idx1 ON pdo_exec_ddl', 0);
+			exec_and_count(7, $db, 'ALTER TABLE pdo_exec_ddl DROP id', 0);
+			exec_and_count(8, $db, 'ALTER TABLE pdo_exec_ddl ADD id INT', 0);
+			exec_and_count(9, $db, 'ALTER TABLE pdo_exec_ddl ALTER id SET DEFAULT 1', 0);
+			exec_and_count(10, $db, 'RENAME TABLE pdo_exec_ddl TO pdo_exec_ddl2', 0);
+		}
+
+		/*
+		11.1.2. ALTER LOGFILE GROUP Syntax
+		11.1.3. ALTER SERVER Syntax
+		11.1.5. ALTER TABLESPACE Syntax
+		11.1.8. CREATE LOGFILE GROUP Syntax
+		11.1.9. CREATE SERVER Syntax
+		11.1.11. CREATE TABLESPACE Syntax
+		11.1.14. DROP LOGFILE GROUP Syntax
+		11.1.15. DROP SERVER Syntax
+		11.1.17. DROP TABLESPACE Syntax
+		*/
+
+	} catch (PDOException $e) {
+		printf("[001] %s, [%s] %s\n",
+			$e->getMessage(),
+			$db->errorCode(), implode(' ', $db->errorInfo()));
+	}
+
+	print "done!";
+--EXPECTF--
+done!
\ No newline at end of file

Thread
PHP mysqlnd svn commit: r1221 - trunk/tests/ext/pdo_mysqluwendel25 Jan