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