1--TEST-- 2MySQL PDOStatement->errorInfo(); 3--SKIPIF-- 4<?php 5require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'skipif.inc'); 6require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); 7MySQLPDOTest::skip(); 8$db = MySQLPDOTest::factory(); 9?> 10--FILE-- 11<?php 12 require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); 13 $db = MySQLPDOTest::factory(); 14 MySQLPDOTest::createTestTable($db); 15 16 printf("Testing emulated PS...\n"); 17 try { 18 $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 1); 19 if (1 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) 20 printf("[002] Unable to turn on emulated prepared statements\n"); 21 22 $stmt = $db->prepare('SELECT id FROM ihopeitdoesnotexist ORDER BY id ASC'); 23 var_dump($stmt->errorInfo()); 24 $stmt->execute(); 25 var_dump($stmt->errorInfo()); 26 27 MySQLPDOTest::createTestTable($db); 28 $stmt = $db->prepare('SELECT label FROM test ORDER BY id ASC LIMIT 1'); 29 $db->exec('DROP TABLE test'); 30 var_dump($stmt->execute()); 31 var_dump($stmt->errorInfo()); 32 var_dump($db->errorInfo()); 33 34 } catch (PDOException $e) { 35 printf("[001] %s [%s] %s\n", 36 $e->getMessage(), $db->errorInfo(), implode(' ', $db->errorInfo())); 37 } 38 39 printf("Testing native PS...\n"); 40 try { 41 $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0); 42 if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY)) 43 printf("[004] Unable to turn off emulated prepared statements\n"); 44 45 $stmt = $db->prepare('SELECT id FROM ihopeitdoesnotexist ORDER BY id ASC'); 46 var_dump($stmt); 47 48 MySQLPDOTest::createTestTable($db); 49 $stmt = $db->prepare('SELECT label FROM test ORDER BY id ASC LIMIT 1'); 50 var_dump($stmt->errorInfo()); 51 $db->exec('DROP TABLE test'); 52 $stmt->execute(); 53 var_dump($stmt->errorInfo()); 54 var_dump($db->errorInfo()); 55 56 } catch (PDOException $e) { 57 printf("[003] %s [%s] %s\n", 58 $e->getMessage(), $db->errorInfo(), implode(' ', $db->errorInfo())); 59 } 60 print "done!"; 61?> 62--CLEAN-- 63<?php 64require dirname(__FILE__) . '/mysql_pdo_test.inc'; 65MySQLPDOTest::dropTestTable(); 66?> 67--EXPECTF-- 68Testing emulated PS... 69array(3) { 70 [0]=> 71 string(0) "" 72 [1]=> 73 NULL 74 [2]=> 75 NULL 76} 77 78Warning: PDOStatement::execute(): SQLSTATE[42S02]: Base table or view not found: 1146 Table '%s.ihopeitdoesnotexist' doesn't exist in %s on line %d 79array(3) { 80 [0]=> 81 string(5) "42S02" 82 [1]=> 83 int(1146) 84 [2]=> 85 string(%d) "Table '%s.ihopeitdoesnotexist' doesn't exist" 86} 87 88Warning: PDOStatement::execute(): SQLSTATE[42S02]: Base table or view not found: 1146 Table '%s.test' doesn't exist in %s on line %d 89bool(false) 90array(3) { 91 [0]=> 92 string(5) "42S02" 93 [1]=> 94 int(1146) 95 [2]=> 96 string(%d) "Table '%s.test' doesn't exist" 97} 98array(3) { 99 [0]=> 100 string(5) "00000" 101 [1]=> 102 NULL 103 [2]=> 104 NULL 105} 106Testing native PS... 107 108Warning: PDO::prepare(): SQLSTATE[42S02]: Base table or view not found: 1146 Table '%s.ihopeitdoesnotexist' doesn't exist in %s on line %d 109bool(false) 110array(3) { 111 [0]=> 112 string(0) "" 113 [1]=> 114 NULL 115 [2]=> 116 NULL 117} 118 119Warning: PDOStatement::execute(): SQLSTATE[42S02]: Base table or view not found: 1146 Table '%s.test' doesn't exist in %s on line %d 120array(3) { 121 [0]=> 122 string(5) "42S02" 123 [1]=> 124 int(1146) 125 [2]=> 126 string(%d) "Table '%s.test' doesn't exist" 127} 128array(3) { 129 [0]=> 130 string(5) "00000" 131 [1]=> 132 NULL 133 [2]=> 134 NULL 135} 136done! 137