Bug #74626 [NEW]: PDO ODbC does not paramaterize datetimeoffset in Microsoft SqlServer right

From: Date: Mon, 22 May 2017 02:33:32 +0000
Subject: Bug #74626 [NEW]: PDO ODbC does not paramaterize datetimeoffset in Microsoft SqlServer right
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-209212@lists.php.net to get a copy of this message
From: zippy1981 at gmail dot com Operating system: Windows 10 PHP version: 7.1.5 Package: PDO ODBC Bug Type: Bug Bug description:PDO ODbC does not paramaterize datetimeoffset in Microsoft SqlServer right Description: ------------ Lets say I have the following temp table defined: DROP TABLE IF EXISTS #dateTable; CREATE TABLE #dateTable ( Id INT NOT NULL PRIMARY KEY CLUSTERED IDENTITY (1,1), [timestamp] DATETIMEOFFSET NOT NULL, message NVARCHAR(255) NOT NULL ); And I have an odbc pdo connection $this->cn. I can insert a row with $sql = <<< EOSQL INSERT INTO #dateTable (message, [timestamp]) VALUES ( 'Solid string insert.', '%s' ); EOSQL; $this->cn->exec(sprintf($sql); However, if I paramaterize it like so: $sql = <<< EOSQL INSERT INTO #dateTable (message, [timestamp]) VALUES ( 'Solid string insert.', :timestamp ); EOSQL; $stmt = $this->cn->prepare($sql); None of the following options work: 1. $stmt->execute([date(DATE_ATOM)]); 2. $timestamp = date(DATE_ATOM); $stmt->bindParam(':timestamp', $timestamp); $result = $stmt->execute(); 3. $stmt->bindValue(':timestamp', date(DATE_ATOM)); $result = $stmt->execute(); However, if I do PDO with the SqlSvr driver it works just fine. Test script: --------------- https://github.com/zippy1981/PhpSqlServerDateTime Actual result: -------------- PDOException: SQLSTATE[22018]: Invalid character value for cast specification: 206 [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Operand type clash: text is incompatible with datetimeoffset (SQLExecute[206] at ext\pdo_odbc\odbc_stmt.c:260) -- Edit bug report at https://bugs.php.net/bug.php?id=74626&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=74626&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=74626&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=74626&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=74626&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=74626&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=74626&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=74626&r=needscript Try newer version: https://bugs.php.net/fix.php?id=74626&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=74626&r=support Expected behavior: https://bugs.php.net/fix.php?id=74626&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=74626&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=74626&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=74626&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=74626&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=74626&r=dst IIS Stability: https://bugs.php.net/fix.php?id=74626&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=74626&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=74626&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=74626&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=74626&r=mysqlcfg

« previous php.bugs (#209212) next »