1--TEST-- 2MySQL PDO->exec(), affected rows 3--EXTENSIONS-- 4pdo_mysql 5--SKIPIF-- 6<?php 7require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); 8MySQLPDOTest::skip(); 9?> 10--FILE-- 11<?php 12 function exec_and_count($offset, &$db, $sql, $exp, $suppress_warning = false) { 13 14 try { 15 16 if ($suppress_warning) 17 $ret = @$db->exec($sql); 18 else 19 $ret = $db->exec($sql); 20 21 if ($ret !== $exp) { 22 printf("[%03d] Expecting '%s'/%s got '%s'/%s when running '%s', [%s] %s\n", 23 $offset, $exp, gettype($exp), $ret, gettype($ret), $sql, 24 $db->errorCode(), implode(' ', $db->errorInfo())); 25 return false; 26 } 27 28 } catch (PDOException $e) { 29 printf("[%03d] '%s' has failed, [%s] %s\n", 30 $offset, $sql, $db->errorCode(), implode(' ', $db->errorInfo())); 31 return false; 32 } 33 34 return true; 35 } 36 37 require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); 38 $db = MySQLPDOTest::factory(); 39 MySQLPDOTest::createTestTable($db, MySQLPDOTest::detect_transactional_mysql_engine($db)); 40 41 /* affected rows related */ 42 try { 43 44 @$db->exec('DROP DATABASE IF EXISTS pdo_exec_ddl'); 45 @$db->exec('DROP DATABASE IF EXISTS pdo_exec_ddl2'); 46 if (1 === @$db->exec('CREATE DATABASE pdo_exec_ddl')) { 47 // yippie - we can create databases etc. 48 exec_and_count(3, $db, 'ALTER DATABASE pdo_exec_ddl CHARACTER SET latin1', 1); 49 } 50 51 exec_and_count(4, $db, 'DROP TABLE IF EXISTS pdo_exec_ddl', 0); 52 exec_and_count(5, $db, 'DROP TABLE IF EXISTS pdo_exec_ddl2', 0); 53 if (0 === $db->exec('CREATE TABLE pdo_exec_ddl(id INT, col1 CHAR(2))')) { 54 exec_and_count(5, $db, 'CREATE INDEX idx1 ON pdo_exec_ddl(id)', 0); 55 exec_and_count(6, $db, 'DROP INDEX idx1 ON pdo_exec_ddl', 0); 56 exec_and_count(7, $db, 'ALTER TABLE pdo_exec_ddl DROP id', 0); 57 exec_and_count(8, $db, 'ALTER TABLE pdo_exec_ddl ADD id INT', 0); 58 exec_and_count(9, $db, 'ALTER TABLE pdo_exec_ddl ALTER id SET DEFAULT 1', 0); 59 exec_and_count(10, $db, 'RENAME TABLE pdo_exec_ddl TO pdo_exec_ddl2', 0); 60 } 61 62 /* 63 11.1.2. ALTER LOGFILE GROUP Syntax 64 11.1.3. ALTER SERVER Syntax 65 11.1.5. ALTER TABLESPACE Syntax 66 11.1.8. CREATE LOGFILE GROUP Syntax 67 11.1.9. CREATE SERVER Syntax 68 11.1.11. CREATE TABLESPACE Syntax 69 11.1.14. DROP LOGFILE GROUP Syntax 70 11.1.15. DROP SERVER Syntax 71 11.1.17. DROP TABLESPACE Syntax 72 */ 73 74 } catch (PDOException $e) { 75 printf("[001] %s, [%s] %s\n", 76 $e->getMessage(), 77 $db->errorCode(), implode(' ', $db->errorInfo())); 78 } 79 80 print "done!"; 81--CLEAN-- 82<?php 83require __DIR__ . '/mysql_pdo_test.inc'; 84$db = MySQLPDOTest::factory(); 85MySQLPDOTest::dropTestTable($db); 86// clean up 87@$db->exec('DROP TABLE IF EXISTS pdo_exec_ddl'); 88@$db->exec('DROP TABLE IF EXISTS pdo_exec_ddl2'); 89@$db->exec('DROP DATABASE IF EXISTS pdo_exec_ddl'); 90@$db->exec('DROP DATABASE IF EXISTS pdo_exec_ddl2'); 91?> 92--EXPECT-- 93done! 94