1--TEST-- 2Bug #47803 Executing prepared statements is successful only for the first two statements 3--EXTENSIONS-- 4odbc 5--SKIPIF-- 6<?php include 'skipif.inc'; ?> 7--FILE-- 8<?php 9 10include __DIR__ . "/config.inc"; 11 12$create_table = "CREATE TABLE bug47803( 13 [PAR_ID] [int] NOT NULL, 14 [PAR_INT] [int] NULL, 15 [PAR_CHR] [varchar](500) NULL 16)"; 17 18$inserts = "INSERT INTO bug47803 19 ([PAR_ID] 20 ,[PAR_INT] 21 ,[PAR_CHR]) 22 VALUES 23 (1,14,''), 24 (2,30,''), 25 (3,7,''), 26 (4,7,''), 27 (5,0,''), 28 (6,0,''), 29 (7,20130901,''), 30 (8,20140201,''), 31 (9,20140201,''), 32 (10,20140620,''), 33 (11,221,'')"; 34 35 36date_default_timezone_set('Europe/Warsaw'); 37 38$link = odbc_connect($dsn, $user, $pass); 39 40odbc_exec($link, $create_table); 41odbc_exec($link, $inserts); 42 43$upd_params = array( 44 array('id'=>1, 'name'=>'test 1'), 45 array('id'=>2, 'name'=>'test 2'), 46 array('id'=>3, 'name'=>'test 3'), 47 array('id'=>4, 'name'=>'test 4'), 48 array('id'=>5, 'name'=>'test 5'), 49 array('id'=>10, 'name'=>'test 10'), 50 array('id'=>9, 'name'=>'test 9'), 51 array('id'=>8, 'name'=>'test 8'), 52 array('id'=>7, 'name'=>'test 7'), 53 array('id'=>6, 'name'=>'test 6'), 54); 55$sql = "UPDATE bug47803 56 SET [PAR_CHR] = ? 57 WHERE [PAR_ID] = ?"; 58$result = odbc_prepare($link, $sql); 59if (!$result) { 60 print ('[sql] prep: '.$sql); 61 goto out; 62} 63foreach ($upd_params as &$k) { 64 if(!odbc_execute($result, array($k['name'], $k['id']))) { 65 print ('[sql] exec: '."array({$k['name']}, {$k['id']})"); 66 goto out; 67 } 68} 69odbc_free_result($result); 70 71$sql = "SELECT * FROM bug47803 WHERE [PAR_ID] = ?"; 72$result = odbc_prepare($link, $sql); 73if (!$result) { 74 print ('[sql] prep: '.$sql); 75 goto out; 76} 77foreach ($upd_params as $k) { 78 if(!odbc_execute($result, array($k['id']))) { 79 print ('[sql] exec: '."array({$k['id']})"); 80 goto out; 81 } 82 while (($r = odbc_fetch_array($result)) !== false) { 83 var_dump($r); 84 } 85} 86 87out: 88if ($result) odbc_free_result($result); 89odbc_close($link); 90 91?> 92--CLEAN-- 93<?php 94include 'config.inc'; 95 96$conn = odbc_connect($dsn, $user, $pass); 97 98odbc_exec($conn, 'DROP TABLE bug47803'); 99 100odbc_close($conn); 101 102?> 103--EXPECT-- 104array(3) { 105 ["PAR_ID"]=> 106 string(1) "1" 107 ["PAR_INT"]=> 108 string(2) "14" 109 ["PAR_CHR"]=> 110 string(6) "test 1" 111} 112array(3) { 113 ["PAR_ID"]=> 114 string(1) "2" 115 ["PAR_INT"]=> 116 string(2) "30" 117 ["PAR_CHR"]=> 118 string(6) "test 2" 119} 120array(3) { 121 ["PAR_ID"]=> 122 string(1) "3" 123 ["PAR_INT"]=> 124 string(1) "7" 125 ["PAR_CHR"]=> 126 string(6) "test 3" 127} 128array(3) { 129 ["PAR_ID"]=> 130 string(1) "4" 131 ["PAR_INT"]=> 132 string(1) "7" 133 ["PAR_CHR"]=> 134 string(6) "test 4" 135} 136array(3) { 137 ["PAR_ID"]=> 138 string(1) "5" 139 ["PAR_INT"]=> 140 string(1) "0" 141 ["PAR_CHR"]=> 142 string(6) "test 5" 143} 144array(3) { 145 ["PAR_ID"]=> 146 string(2) "10" 147 ["PAR_INT"]=> 148 string(8) "20140620" 149 ["PAR_CHR"]=> 150 string(7) "test 10" 151} 152array(3) { 153 ["PAR_ID"]=> 154 string(1) "9" 155 ["PAR_INT"]=> 156 string(8) "20140201" 157 ["PAR_CHR"]=> 158 string(6) "test 9" 159} 160array(3) { 161 ["PAR_ID"]=> 162 string(1) "8" 163 ["PAR_INT"]=> 164 string(8) "20140201" 165 ["PAR_CHR"]=> 166 string(6) "test 8" 167} 168array(3) { 169 ["PAR_ID"]=> 170 string(1) "7" 171 ["PAR_INT"]=> 172 string(8) "20130901" 173 ["PAR_CHR"]=> 174 string(6) "test 7" 175} 176array(3) { 177 ["PAR_ID"]=> 178 string(1) "7" 179 ["PAR_INT"]=> 180 string(8) "20130901" 181 ["PAR_CHR"]=> 182 string(6) "test 7" 183} 184