1--TEST--
2MySQL PDOStatement->closeCursor()
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--FILE--
11<?php
12    require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
13    $db = MySQLPDOTest::factory();
14
15
16    try {
17
18        $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0);
19        if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY))
20            printf("[002] Unable to turn off emulated prepared statements\n");
21
22        $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false);
23        MySQLPDOTest::createTestTable($db);
24
25        $stmt = $db->prepare('SELECT id, label FROM test WHERE id > ? ORDER BY id ASC LIMIT 2');
26        $in = 0;
27        if (!$stmt->bindParam(1, $in))
28            printf("[003] Cannot bind parameter, %s %s\n",
29                $stmt->errorCode(), var_export($stmt->errorInfo(), true));
30
31        $stmt->execute();
32        $id = $label = null;
33
34        if (!$stmt->bindColumn(1, $id, PDO::PARAM_INT))
35            printf("[004] Cannot bind integer column, %s %s\n",
36                $stmt->errorCode(), var_export($stmt->errorInfo(), true));
37
38        if (!$stmt->bindColumn(2, $label, PDO::PARAM_STR))
39            printf("[005] Cannot bind string column, %s %s\n",
40                $stmt->errorCode(), var_export($stmt->errorInfo(), true));
41
42        while ($stmt->fetch(PDO::FETCH_BOUND))
43            printf("in = %d -> id = %s (%s) / label = %s (%s)\n",
44                $in,
45                var_export($id, true), gettype($id),
46                var_export($label, true), gettype($label));
47
48        $stmt->closeCursor();
49        $stmt->execute();
50        while ($stmt->fetch(PDO::FETCH_BOUND))
51            printf("in = %d -> id = %s (%s) / label = %s (%s)\n",
52                $in,
53                var_export($id, true), gettype($id),
54                var_export($label, true), gettype($label));
55
56    } catch (PDOException $e) {
57        printf("[001] %s [%s] %s\n",
58            $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo()));
59    }
60
61    $db->exec('DROP TABLE IF EXISTS test');
62    print "done!";
63?>
64--CLEAN--
65<?php
66require __DIR__ . '/mysql_pdo_test.inc';
67MySQLPDOTest::dropTestTable();
68?>
69--EXPECT--
70in = 0 -> id = 1 (integer) / label = 'a' (string)
71in = 0 -> id = 2 (integer) / label = 'b' (string)
72in = 0 -> id = 1 (integer) / label = 'a' (string)
73in = 0 -> id = 2 (integer) / label = 'b' (string)
74done!
75