From:             aspen dot olmsted at alliance dot biz
Operating system: Windows 2003, XP
PHP version:      5.2.1
PHP Bug Type:     PDO related
Bug description:  ODBC and SQL Server datetime parameter fields fail on insert

Description:
------------
If you have MS SQL datetime field using odbc and try to use parameterized
inserts you get a sql sequence error.

Reproduce code:
---------------
Here is sql to create table

CREATE TABLE [ASC_EventPreSale] (
        [apsEventCode] [int] NOT NULL CONSTRAINT
[DF_ASC_EventPreSale_apsEventCode] DEFAULT (0),
        [apsStartDate] [datetime] NOT NULL CONSTRAINT
[DF_ASC_EventPreSale_apsStartDate] DEFAULT (getdate()),
        [apsFinishDate] [datetime] NOT NULL CONSTRAINT
[DF_ASC_EventPreSale_apsFinishDate] DEFAULT (getdate()),
        [apsGeneralPublicDate] [datetime] NOT NULL CONSTRAINT
[DF_ASC_EventPreSale_apsGeneralPublicDate] DEFAULT (getdate()),
        CONSTRAINT [PK_ASC_EventPreSale] PRIMARY KEY  CLUSTERED 
        (
                [apsEventCode]
        )  ON [PRIMARY] 
) ON [PRIMARY]
GO


Here is php
<?php
$sql ="INSERT INTO ASC_EventPreSale
(apsEventCode,apsStartDate,apsFinishDate,apsGeneralPublicDate) VALUES
(:apsEventCode,:apsStartDate,:apsFinishDate,:apsGeneralPublicDate)";

$avalues['apsEventCode'] = 6339;
$avalues['apsStartDate'] = '2007-02-12 14:5';
$avalues['apsFinishDate'] = '2007-02-12 16:5';
$avalues['apsGeneralPublicDate'] = '2007-02-15 14:5';

$stmt=$dbh->prepare($sql);
$stmt->execute($avalues);
?>

Expected result:
----------------
If you change the field types to varchar it works fine.  It should
function the same with date time fields

Actual result:
--------------
SQL Error

-- 
Edit bug report at http://bugs.php.net/?id=40452&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=40452&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=40452&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=40452&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=40452&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=40452&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=40452&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=40452&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=40452&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=40452&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=40452&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=40452&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=40452&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=40452&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=40452&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=40452&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=40452&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=40452&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=40452&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=40452&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=40452&r=mysqlcfg

Reply via email to