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