List:Commits« Previous MessageNext Message »
From:uwendel Date:October 19 2007 11:41am
Subject:PHP mysqlnd svn commit: r1117 - trunk/tests/ext/pdo
View as plain text  
Author: uwendel
Date: 2007-10-19 13:41:42 +0200 (Fri, 19 Oct 2007)
New Revision: 1117

Added:
   trunk/tests/ext/pdo/pdo_errorcode.phpt
Log:
Run it and enjoy. Watch out for the PS stuff:

prepare(<no bind columns>); 
execute(); 
bindParam(<nonexisting bind column>, <someval>);
errorCode() -> 00000 = none



Added: trunk/tests/ext/pdo/pdo_errorcode.phpt
===================================================================
--- trunk/tests/ext/pdo/pdo_errorcode.phpt	2007-10-19 11:39:08 UTC (rev 1116)
+++ trunk/tests/ext/pdo/pdo_errorcode.phpt	2007-10-19 11:41:42 UTC (rev 1117)
@@ -0,0 +1,63 @@
+--TEST--
+PDO Common: PDO->errorCode()
+--SKIPIF--
+<?php # vim:ft=php
+if (!extension_loaded('pdo')) die('skip');
+$dir = getenv('REDIR_TEST_DIR');
+if (false == $dir) die('skip no driver');
+require_once $dir . 'pdo_test.inc';
+PDOTest::skip();
+?>
+--FILE--
+<?php
+if (getenv('REDIR_TEST_DIR') === false) putenv('REDIR_TEST_DIR='.dirname(__FILE__) .
'/../../pdo/tests/');
+require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
+$db = PDOTest::factory('PDO', false);
+
+if (false !== ($tmp = $db->errorCode("too many arguments")))
+	printf("[001] Expecting boolean/false got %s/%s\n", $tmp, gettype($tmp));
+
+if ('' !== ($tmp = $db->errorCode()))
+	printf("[002] Expecting empty string got %s/%s\n", $tmp, gettype($tmp));
+
+$db->exec('THIS IS NO VALID SQL, I HOPE');
+// keep this one var_dump() for future unicode testing and PHP 6
+var_dump($db->errorCode());
+
+$db->exec('CREATE TABLE test(id int NOT NULL PRIMARY KEY, val VARCHAR(10), grp
VARCHAR(10))');
+if ('00000' !== ($tmp = $db->errorCode()))
+	printf("[003] CREATE TABLE has failed, test will fail, [%s} [%s]\n",
+		$db->errorCode(), implode(' ', $db->errorInfo()));
+
+$db->exec('INSERT INTO test(id, val, grp) VALUES(1, \'A\', \'Group1\')');
+if ('00000' !== ($tmp = $db->errorCode()))
+	printf("[004] INSERT has failed, test will fail, [%s} [%s]\n",
+		$db->errorCode(), implode(' ', $db->errorInfo()));
+
+$stmt = $db->prepare('SELECT id, val FROM test');
+if (!is_object($stmt))
+	printf("[005] Creating a statement object has failed, test will fail, [%s] %s\n",
+		$db->errorCode(), implode(' ', $db->errorInfo()));
+
+if ('00000' !== ($tmp = $db->errorCode()))
+	printf("[006] Unexpected error code, [%s] %s\n",
+		$db->errorCode(), implode(' ', $db->errorInfo()));
+
+$stmt->execute();
+$param = 'there is no placehulder to bind';
+$stmt->bindParam(1, $param);
+if ('00000' !== ($tmp = $db->errorCode()))
+	printf("[007] Unexpected error code, [%s] %s\n",
+		$db->errorCode(), implode(' ', $db->errorInfo()));
+
+$tmp = $stmt->errorCode();
+if (('00000' == $tmp) || (strlen($tmp) < 5))
+	printf("[008] Shouldn't the statement indicate an error after: prepare(<no
placeholder>); execute(); bindParam(<to non existing placeholder>)? [%s] %s\n",
+		$stmt->errorCode(), implode(' ', $stmt->errorInfo()));
+
+print "done!";
+?>
+--EXPECTF--
+Warning: PDO::exec(): SQLSTATE[%s]: %s in %s on line %d
+string(5) "%s"
+done!
\ No newline at end of file

Thread
PHP mysqlnd svn commit: r1117 - trunk/tests/ext/pdouwendel19 Oct