-
Notifications
You must be signed in to change notification settings - Fork 7.8k
/
Copy pathpdo_028.phpt
45 lines (40 loc) · 1.01 KB
/
pdo_028.phpt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
--TEST--
PDO Common: bindValue
--SKIPIF--
<?php # vim:ft=php
if (!extension_loaded('pdo')) die('skip');
$dir = getenv('REDIR_TEST_DIR');
if (false == $dir) die('skip no driver');
require_once $dir . 'pdo_test.inc';
PDOTest::skip();
?>
--FILE--
<?php
if (getenv('REDIR_TEST_DIR') === false) putenv('REDIR_TEST_DIR='.dirname(__FILE__) . '/../../pdo/tests/');
require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
$db = PDOTest::factory();
$db->exec('CREATE TABLE test(id int NOT NULL PRIMARY KEY, val1 VARCHAR(10), val2 VARCHAR(10), val3 VARCHAR(10))');
$stmt = $db->prepare('INSERT INTO test values (1, ?, ?, ?)');
$data = array("one", "two", "three");
foreach ($data as $i => $v) {
$stmt->bindValue($i+1, $v);
}
$stmt->execute();
$stmt = $db->prepare('SELECT * from test');
$stmt->execute();
var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
?>
--EXPECT--
array(1) {
[0]=>
array(4) {
["id"]=>
string(1) "1"
["val1"]=>
string(3) "one"
["val2"]=>
string(3) "two"
["val3"]=>
string(5) "three"
}
}