xref: /php-src/ext/pdo/tests/pdo_028.phpt (revision f4a5db3e)
1--TEST--
2PDO Common: bindValue
3--EXTENSIONS--
4pdo
5--SKIPIF--
6<?php
7$dir = getenv('REDIR_TEST_DIR');
8if (false == $dir) die('skip no driver');
9require_once $dir . 'pdo_test.inc';
10PDOTest::skip();
11?>
12--FILE--
13<?php
14if (getenv('REDIR_TEST_DIR') === false) putenv('REDIR_TEST_DIR='.__DIR__ . '/../../pdo/tests/');
15require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
16$db = PDOTest::factory();
17
18$db->exec('CREATE TABLE test028(id int NOT NULL PRIMARY KEY, val1 VARCHAR(10), val2 VARCHAR(10), val3 VARCHAR(10))');
19$stmt = $db->prepare('INSERT INTO test028 values (1, ?, ?, ?)');
20
21$data = array("one", "two", "three");
22
23foreach ($data as $i => $v) {
24    $stmt->bindValue($i+1, $v);
25}
26$stmt->execute();
27
28$stmt = $db->prepare('SELECT * from test028');
29$stmt->execute();
30
31var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
32?>
33--CLEAN--
34<?php
35require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
36$db = PDOTest::factory();
37PDOTest::dropTableIfExists($db, "test028");
38?>
39--EXPECT--
40array(1) {
41  [0]=>
42  array(4) {
43    ["id"]=>
44    string(1) "1"
45    ["val1"]=>
46    string(3) "one"
47    ["val2"]=>
48    string(3) "two"
49    ["val3"]=>
50    string(5) "three"
51  }
52}
53