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 17@odbc_exec($conn, 'CREATE DATABASE odbcTEST'); 18 19odbc_exec($conn, 'CREATE TABLE FOO (ID INT, VARCHAR_COL VARCHAR(100), DATE_COL DATE)'); 20 21odbc_exec($conn, "INSERT INTO FOO(ID, VARCHAR_COL, DATE_COL) VALUES (1, 'hello', '$id_1_date')"); 22odbc_exec($conn, "INSERT INTO FOO(ID, VARCHAR_COL, DATE_COL) VALUES (2, 'helloagain', '$id_2_date')"); 23 24$res = odbc_exec($conn, 'SELECT * FROM FOO ORDER BY ID ASC'); 25 26while(odbc_fetch_row($res)) { 27 $id = odbc_result($res, "ID"); 28 $varchar_col = odbc_result($res, "VARCHAR_COL"); 29 $date = odbc_result($res, "DATE_COL"); 30 31 if ($id == 1) { 32 if ($date != $id_1_date) { 33 print "Date_1 mismatched\n"; 34 } else { 35 print "Date_1 matched\n"; 36 } 37 } else { 38 if ($date != $id_2_date) { 39 print "Date_2 mismatched\n"; 40 } else { 41 print "Date_2 matched\n"; 42 } 43 } 44} 45 46?> 47--EXPECT-- 48Date_1 matched 49Date_2 matched 50--CLEAN-- 51<?php 52include 'config.inc'; 53 54$conn = odbc_connect($dsn, $user, $pass); 55 56odbc_exec($conn, 'DROP TABLE FOO'); 57odbc_exec($conn, 'DROP DATABASE odbcTEST'); 58 59?> 60