xref: /PHP-8.3/ext/odbc/tests/bug68087.phpt (revision 8726ae06)
1--TEST--
2odbc_exec(): Getting accurate date data from query
3--EXTENSIONS--
4odbc
5--SKIPIF--
6<?php include 'skipif.inc'; ?>
7--FILE--
8<?php
9
10include 'config.inc';
11
12$id_1_date = '2014-09-23';
13$id_2_date = '2014-09-24';
14
15$conn = odbc_connect($dsn, $user, $pass);
16
17odbc_exec($conn, 'CREATE TABLE bug68087 (ID INT, VARCHAR_COL VARCHAR(100), DATE_COL DATE)');
18
19odbc_exec($conn, "INSERT INTO bug68087(ID, VARCHAR_COL, DATE_COL) VALUES (1, 'hello', '$id_1_date'), (2, 'helloagain', '$id_2_date')");
20
21$res = odbc_exec($conn, 'SELECT * FROM bug68087 ORDER BY ID ASC');
22
23while(odbc_fetch_row($res)) {
24    $id = odbc_result($res, "ID");
25    $varchar_col = odbc_result($res, "VARCHAR_COL");
26    $date = odbc_result($res, "DATE_COL");
27
28    if ($id == 1) {
29        if ($date != $id_1_date) {
30            print "Date_1 mismatched\n";
31        } else {
32            print "Date_1 matched\n";
33        }
34    } else {
35        if ($date != $id_2_date) {
36            print "Date_2 mismatched\n";
37        } else {
38            print "Date_2 matched\n";
39        }
40    }
41}
42
43?>
44--CLEAN--
45<?php
46include 'config.inc';
47
48$conn = odbc_connect($dsn, $user, $pass);
49
50odbc_exec($conn, 'DROP TABLE bug68087');
51
52?>
53--EXPECT--
54Date_1 matched
55Date_2 matched
56