Author: uwendel
Date: 2008-01-25 11:48:40 +0100 (Fri, 25 Jan 2008)
New Revision: 1222
Added:
trunk/tests/ext/pdo_mysql/pdo_mysql_exec_load_data.phpt
Modified:
trunk/tests/ext/pdo_mysql/TODO_TESTING
Log:
Very simple LOAD DATA INFILE
Modified: trunk/tests/ext/pdo_mysql/TODO_TESTING
===================================================================
--- trunk/tests/ext/pdo_mysql/TODO_TESTING 2008-01-25 10:11:56 UTC (rev 1221)
+++ trunk/tests/ext/pdo_mysql/TODO_TESTING 2008-01-25 10:48:40 UTC (rev 1222)
@@ -18,7 +18,7 @@
PDO::__construct ---> 100%
PDO::errorCode() ---> 100%
PDO::errorInfo() ---> 100%
-PDO::exec() ---> 30%
+PDO::exec() ---> 80%
PDO::getAttribute() ---> 5%
PDO::getAvailableDrivers() ---> 100%
PDO::lastInsertId() ---> 100%
@@ -127,16 +127,22 @@
[m] will two PDOStatement/PDO objects influence each other error codes?
-PDO::exec() ---> 30%
+PDO::exec() ---> 80%
pdo_exec.phpt
pdo_mysql_exec.phpt
pdo_mysql_exec_ddl.phpt
+ pdo_mysql_exec_load_data.phpt
[g] invalid parameter
[m] most SQL DDL statements
+ [m] most SQL DML statements
+ [m] LOAD DATA INFILE
+ [m] stored function
+ [m] stored procedure
[m] affected rows: DELETE. INSERT, REPLACE, TRUNCATE, UPDATE, LOAD DATA, LOAD XML
[ ] single / multiple result set statements
+ [m] multi query
[g] 0 vs. false
Added: trunk/tests/ext/pdo_mysql/pdo_mysql_exec_load_data.phpt
===================================================================
--- trunk/tests/ext/pdo_mysql/pdo_mysql_exec_load_data.phpt (rev
0)
+++ trunk/tests/ext/pdo_mysql/pdo_mysql_exec_load_data.phpt 2008-01-25 10:48:40 UTC (rev
1222)
@@ -0,0 +1,87 @@
+--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 TABLE IF EXISTS test', 0);
+ exec_and_count(3, $db, sprintf('CREATE TABLE test(id INT NOT NULL PRIMARY KEY, col1
CHAR(10)) ENGINE=%s', PDO_MYSQL_TEST_ENGINE), 0);
+
+ $filename = MySQLPDOTest::getTempDir() . DIRECTORY_SEPARATOR .
"pdo_mysql_exec_load_data.csv";
+ $fp = fopen($filename, "w");
+ fwrite($fp, b"1;foo\n");
+ fwrite($fp, b"2;bar");
+ fclose($fp);
+
+ $sql = sprintf("LOAD DATA INFILE %s INTO TABLE test FIELDS TERMINATED BY ';' LINES
TERMINATED BY '\n'", $db->quote($filename));
+ exec_and_count(4, $db, $sql, 2);
+
+ $stmt = $db->query('SELECT id, col1 FROM test ORDER BY id ASC');
+ var_dump($stmt->fetchAll());
+ unlink($filename);
+
+ } catch (PDOException $e) {
+ printf("[001] %s, [%s] %s\n",
+ $e->getMessage(),
+ $db->errorCode(), implode(' ', $db->errorInfo()));
+ }
+
+ print "done!";
+--EXPECTF--
+array(2) {
+ [0]=>
+ array(4) {
+ ["id"]=>
+ string(1) "1"
+ [0]=>
+ string(1) "1"
+ ["col1"]=>
+ string(3) "foo"
+ [1]=>
+ string(3) "foo"
+ }
+ [1]=>
+ array(4) {
+ ["id"]=>
+ string(1) "2"
+ [0]=>
+ string(1) "2"
+ ["col1"]=>
+ string(3) "bar"
+ [1]=>
+ string(3) "bar"
+ }
+}
+done!
\ No newline at end of file
| Thread |
|---|
| • PHP mysqlnd svn commit: r1222 - trunk/tests/ext/pdo_mysql | uwendel | 25 Jan |