1
0
mirror of https://github.com/php/php-src.git synced 2026-04-04 22:52:40 +02:00

Merge branch 'PHP-5.6' into PHP-7.0

* PHP-5.6:
  Fixed #54648 PDO::MSSQL forces format of datetime fields
This commit is contained in:
Anatol Belski
2016-02-29 17:07:05 +01:00
2 changed files with 45 additions and 0 deletions

View File

@@ -268,6 +268,25 @@ static int pdo_dblib_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr,
*ptr = tmp_ptr;
break;
}
case SQLDATETIM4:
case SQLDATETIME: {
DBDATETIME dt;
DBDATEREC di;
dbconvert(H->link, coltype, (BYTE*) *ptr, -1, SQLDATETIME, (LPBYTE) &dt, -1);
dbdatecrack(H->link, &di, &dt);
*len = spprintf((char**) &tmp_ptr, 20, "%d-%02d-%02d %02d:%02d:%02d",
#ifdef PHP_DBLIB_IS_MSSQL || MSDBLIB
di.year, di.month, di.day, di.hour, di.minute, di.second
#else
di.dateyear, di.datemonth+1, di.datedmonth, di.datehour, di.dateminute, di.datesecond
#endif
);
*ptr = (char*) tmp_ptr;
break;
}
default:
if (dbwillconvert(coltype, SQLCHAR)) {
tmp_len = 32 + (2 * (*len)); /* FIXME: We allocate more than we need here */

View File

@@ -0,0 +1,26 @@
--TEST--
PDO_DBLIB: Does not force correct dateformat
--SKIPIF--
<?php
if (!extension_loaded('pdo_dblib')) die('skip not loaded');
require dirname(__FILE__) . '/config.inc';
?>
--FILE--
<?php
require dirname(__FILE__) . '/config.inc';
$db->query('set dateformat ymd');
$rs = $db->query("select cast('1950-01-18 23:00:00' as smalldatetime) as sdt, cast('2030-01-01 23:59:59' as datetime) as dt");
var_dump($rs->fetchAll(PDO::FETCH_ASSOC));
echo "Done.\n";
?>
--EXPECT--
array(1) {
[0]=>
array(2) {
["sdt"]=>
string(19) "1950-01-18 23:00:00"
["dt"]=>
string(19) "2030-01-01 23:59:59"
}
}
Done.