PHP  
 PHP_5_3
downloads | QA | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
 

Test Failure Report for ext/pdo_mysql/tests/pdo_mysql_stmt_multiquery.phpt ('PDOStatements and multi query')

Script

1: <?php
2:     
require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR 'mysql_pdo_test.inc');
3:
4:     function 
mysql_stmt_multiquery_wrong_usage($db) {
5:
6:         
$stmt $db->query('SELECT label FROM test ORDER BY id ASC LIMIT 1; SELECT label FROM test ORDER BY id ASC LIMIT 1');
7:         
var_dump($stmt->errorInfo());
8:         
var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
9:         
var_dump($stmt->errorInfo());
10:
11:     }
12:
13:     function 
mysql_stmt_multiquery_proper_usage($db) {
14:
15:         
$stmt $db->query('SELECT label FROM test ORDER BY id ASC LIMIT 1; SELECT label FROM test ORDER BY id ASC LIMIT 1');
16:         do {
17:             
var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
18:         } while (
$stmt->nextRowset());
19:
20:     }
21:
22:     try {
23:
24:         
printf("Emulated Prepared Statements...\n");
25:         
$db MySQLPDOTest::factory();
26:         
MySQLPDOTest::createTestTable($db);
27:         
$db->setAttribute(PDO::ATTR_EMULATE_PREPARES1);
28:         
mysql_stmt_multiquery_wrong_usage($db);
29:         
mysql_stmt_multiquery_proper_usage($db);
30:
31:         
printf("Native Prepared Statements...\n");
32:         
$db MySQLPDOTest::factory();
33:         
MySQLPDOTest::createTestTable($db);
34:         
$db->setAttribute(PDO::ATTR_EMULATE_PREPARES0);
35:         
mysql_stmt_multiquery_wrong_usage($db);
36:         
mysql_stmt_multiquery_proper_usage($db);
37:
38:     } catch (
PDOException $e) {
39:         
printf("[001] %s [%s] %s\n",
40:             
$e->getMessage(), $db->errorCode(), implode(' '$db->errorInfo()));
41:     }
42:
43:     print 
"done!";
44:
?>
45:

Expected

Emulated Prepared Statements...
array(3) {
  [0]=>
  %unicode|string%(5) "00000"
  [1]=>
  NULL
  [2]=>
  NULL
}
array(1) {
  [0]=>
  array(1) {
    [%u|b%"label"]=>
    %unicode|string%(1) "a"
  }
}
array(3) {
  [0]=>
  %unicode|string%(5) "00000"
  [1]=>
  NULL
  [2]=>
  NULL
}
array(1) {
  [0]=>
  array(1) {
    [%u|b%"label"]=>
    %unicode|string%(1) "a"
  }
}
array(1) {
  [0]=>
  array(1) {
    [%u|b%"label"]=>
    %unicode|string%(1) "a"
  }
}
Native Prepared Statements...

Warning: PDO::query(): SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '%SSELECT label FROM test ORDER BY id ASC LIMIT 1' at line %d in %s on line %d

Fatal error: Call to a member function errorInfo() on a non-object in %s on line %d

Output

Emulated Prepared Statements...
array(3) {
  [0]=>
  string(5) "00000"
  [1]=>
  NULL
  [2]=>
  NULL
}
array(1) {
  [0]=>
  array(1) {
    ["label"]=>
    string(1) "a"
  }
}
array(3) {
  [0]=>
  string(5) "00000"
  [1]=>
  NULL
  [2]=>
  NULL
}
array(1) {
  [0]=>
  array(1) {
    ["label"]=>
    string(1) "a"
  }
}
Native Prepared Statements...

Warning: PDO::query(): SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT label FROM test ORDER BY id ASC LIMIT 1' at line 1 in /var/php_gcov/PHP_5_3/ext/pdo_mysql/tests/pdo_mysql_stmt_multiquery.php on line 6

Fatal error: Call to a member function errorInfo() on a non-object in /var/php_gcov/PHP_5_3/ext/pdo_mysql/tests/pdo_mysql_stmt_multiquery.php on line 7

Diff

032+ Native Prepared Statements...
033+ 
034+ Warning: PDO::query(): SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT label FROM test ORDER BY id ASC LIMIT 1' at line 1 in /var/php_gcov/PHP_5_3/ext/pdo_mysql/tests/pdo_mysql_stmt_multiquery.php on line 6
032- array(1) {
033-   [0]=>
034-   array(1) {
035-     [%u|b%"label"]=>
036-     %unicode|string%(1) "a"
037-   }
038- }
039- Native Prepared Statements...
041- Warning: PDO::query(): SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '%SSELECT label FROM test ORDER BY id ASC LIMIT 1' at line %d in %s on line %d
042- 

 

Generated at Sun, 27 Jul 2014 12:58:43 +0000 (19 hours ago)

Copyright © 2005-2014 The PHP Group
All rights reserved.