1--TEST--
2PDO::MYSQL_ATTR_MULTI_STATEMENTS
3--SKIPIF--
4<?php
5require_once(__DIR__ . DIRECTORY_SEPARATOR . 'skipif.inc');
6require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
7MySQLPDOTest::skip();
8$db = MySQLPDOTest::factory();
9?>
10--INI--
11error_reporting=E_ALL
12--FILE--
13<?php
14	require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
15
16	$dsn = MySQLPDOTest::getDSN();
17	$user = PDO_MYSQL_TEST_USER;
18	$pass = PDO_MYSQL_TEST_PASS;
19
20	$table = sprintf("test_%s", md5(mt_rand(0, PHP_INT_MAX)));
21	$db = new PDO($dsn, $user, $pass);
22	$db->exec(sprintf('DROP TABLE IF EXISTS %s', $table));
23	$create = sprintf('CREATE TABLE %s(id INT)', $table);
24	$db->exec($create);
25	$db->exec(sprintf('INSERT INTO %s(id) VALUES (1)', $table));
26	$stmt = $db->query(sprintf('SELECT * FROM %s; INSERT INTO %s(id) VALUES (2)', $table, $table));
27	$stmt->closeCursor();
28	$info = $db->errorInfo();
29	var_dump($info[0]);
30	$stmt = $db->query(sprintf('SELECT id FROM %s', $table));
31	var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
32        // A single query with a trailing delimiter.
33	$stmt = $db->query('SELECT 1 AS value;');
34	var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
35
36	// New connection, does not allow multiple statements.
37	$db = new PDO($dsn, $user, $pass, array(PDO::MYSQL_ATTR_MULTI_STATEMENTS => false));
38	$stmt = $db->query(sprintf('SELECT * FROM %s; INSERT INTO %s(id) VALUES (3)', $table, $table));
39	var_dump($stmt);
40	$info = $db->errorInfo();
41	var_dump($info[0]);
42
43	$stmt = $db->query(sprintf('SELECT id FROM %s', $table));
44	var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
45        // A single query with a trailing delimiter.
46        $stmt = $db->query('SELECT 1 AS value;');
47        var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
48
49	$db->exec(sprintf('DROP TABLE IF EXISTS %s', $table));
50	print "done!";
51?>
52--EXPECT--
53string(5) "00000"
54array(2) {
55  [0]=>
56  array(1) {
57    ["id"]=>
58    string(1) "1"
59  }
60  [1]=>
61  array(1) {
62    ["id"]=>
63    string(1) "2"
64  }
65}
66array(1) {
67  [0]=>
68  array(1) {
69    ["value"]=>
70    string(1) "1"
71  }
72}
73bool(false)
74string(5) "42000"
75array(2) {
76  [0]=>
77  array(1) {
78    ["id"]=>
79    string(1) "1"
80  }
81  [1]=>
82  array(1) {
83    ["id"]=>
84    string(1) "2"
85  }
86}
87array(1) {
88  [0]=>
89  array(1) {
90    ["value"]=>
91    string(1) "1"
92  }
93}
94done!
95