1--TEST--
2PDO::MYSQL_ATTR_INIT_COMMAND
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
24	$create = sprintf('CREATE TABLE %s(id INT)', $table);
25	var_dump($create);
26	$db = new PDO($dsn, $user, $pass, array(PDO::MYSQL_ATTR_INIT_COMMAND => $create));
27
28	$info = $db->errorInfo();
29	var_dump($info[0]);
30
31	$db->exec(sprintf('INSERT INTO %s(id) VALUES (1)', $table));
32	$stmt = $db->query(sprintf('SELECT id FROM %s', $table));
33	var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
34
35	$db->exec(sprintf('DROP TABLE IF EXISTS %s', $table));
36	print "done!";
37?>
38--EXPECTF--
39string(58) "CREATE TABLE test_%s(id INT)"
40string(5) "00000"
41array(1) {
42  [0]=>
43  array(1) {
44    ["id"]=>
45    string(1) "1"
46  }
47}
48done!
49