1--TEST-- 2Bug #42173 (TIMESTAMP and INTERVAL query and field functions) 3--EXTENSIONS-- 4oci8 5--SKIPIF-- 6<?php 7require_once 'skipifconnectfailure.inc'; 8$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs 9require __DIR__.'/skipif.inc'; 10?> 11--FILE-- 12<?php 13 14require __DIR__.'/connect.inc'; 15 16$stmts = array( 17 18"drop table ts_test", 19 20"create table ts_test ( 21c1 TIMESTAMP, 22c2 TIMESTAMP (5), 23c3 TIMESTAMP WITH TIME ZONE, 24c4 TIMESTAMP (2) WITH TIME ZONE, 25c5 TIMESTAMP WITH LOCAL TIME ZONE, 26c6 INTERVAL YEAR TO MONTH, 27c7 INTERVAL YEAR(2) TO MONTH, 28c8 INTERVAL DAY TO SECOND, 29c9 INTERVAL DAY(2) TO SECOND(3) 30)", 31 32"insert into ts_test values ( 33timestamp'1999-01-03 10:00:00.123', 34timestamp'1999-01-04 10:00:00.123456', 35timestamp'1999-01-05 10:00:00.123456+1:0', 36timestamp'1999-01-06 10:00:00.123456-1:0', 37timestamp'1999-01-06 10:00:00.123456-1:0', 38interval'1-2' year to month, 39interval'10-4' year to month, 40interval'1 2:20:20.123' day to second, 41interval'1 2:20:20.12345' day to second)"); 42 43foreach ($stmts as $sql) { 44 $s = oci_parse($c, $sql); 45 $r = @oci_execute($s); 46} 47 48$s = oci_parse($c, "select * from ts_test"); 49$r = oci_execute($s); 50$row = oci_fetch_array($s, OCI_ASSOC); 51var_dump($row); 52 53foreach ($row as $name => $field) { 54 echo "\nColumn $name\n"; 55 var_dump(oci_field_is_null($s, $name)); 56 var_dump(oci_field_name($s, $name)); 57 var_dump(oci_field_type($s, $name)); 58 var_dump(oci_field_type_raw($s, $name)); 59 var_dump(oci_field_scale($s, $name)); 60 var_dump(oci_field_precision($s, $name)); 61 var_dump(oci_field_size($s, $name)); 62} 63 64// Cleanup 65 66$s = oci_parse($c, "drop table ts_test"); 67$r = @oci_execute($s); 68 69echo "Done\n"; 70 71?> 72--EXPECTF-- 73array(9) { 74 ["C1"]=> 75 string(28) "03-JAN-99 10.00.00.123000 AM" 76 ["C2"]=> 77 string(27) "04-JAN-99 10.00.00.12346 AM" 78 ["C3"]=> 79 string(35) "05-JAN-99 10.00.00.123456 AM +01:00" 80 ["C4"]=> 81 string(31) "06-JAN-99 10.00.00.12 AM -01:00" 82 ["C5"]=> 83 string(28) "%s" 84 ["C6"]=> 85 string(6) "+01-02" 86 ["C7"]=> 87 string(6) "+10-04" 88 ["C8"]=> 89 string(19) "+01 02:20:20.123000" 90 ["C9"]=> 91 string(16) "+01 02:20:20.123" 92} 93 94Column C1 95bool(false) 96string(2) "C1" 97string(9) "TIMESTAMP" 98int(187) 99int(6) 100int(0) 101int(11) 102 103Column C2 104bool(false) 105string(2) "C2" 106string(9) "TIMESTAMP" 107int(187) 108int(5) 109int(0) 110int(11) 111 112Column C3 113bool(false) 114string(2) "C3" 115string(23) "TIMESTAMP WITH TIMEZONE" 116int(188) 117int(6) 118int(0) 119int(13) 120 121Column C4 122bool(false) 123string(2) "C4" 124string(23) "TIMESTAMP WITH TIMEZONE" 125int(188) 126int(2) 127int(0) 128int(13) 129 130Column C5 131bool(false) 132string(2) "C5" 133string(29) "TIMESTAMP WITH LOCAL TIMEZONE" 134int(232) 135int(6) 136int(0) 137int(11) 138 139Column C6 140bool(false) 141string(2) "C6" 142string(22) "INTERVAL YEAR TO MONTH" 143int(189) 144int(0) 145int(2) 146int(5) 147 148Column C7 149bool(false) 150string(2) "C7" 151string(22) "INTERVAL YEAR TO MONTH" 152int(189) 153int(0) 154int(2) 155int(5) 156 157Column C8 158bool(false) 159string(2) "C8" 160string(22) "INTERVAL DAY TO SECOND" 161int(190) 162int(6) 163int(2) 164int(11) 165 166Column C9 167bool(false) 168string(2) "C9" 169string(22) "INTERVAL DAY TO SECOND" 170int(190) 171int(3) 172int(2) 173int(11) 174Done 175