From: aspen dot olmsted at alliance dot biz
Operating system: Windows XP SP2
PHP version: 5CVS-2006-10-13 (snap)
PHP Bug Type: PDO related
Bug description: prepared statement with input parameters and db function fails
Description:
------------
If you try to insert a record using MSSQL, ODBC, PDO and windows with a
replacement parameter that is a db function it will fail. The same insert
can be written without replacement parameters using both exec and prepare.
Reproduce code:
---------------
SQL Table:
CREATE TABLE [pdotest] (
[Code] [int] NOT NULL ,
[Description] [varchar] (100)
) ON [PRIMARY]
GO
SQL Function:
CREATE FUNCTION dbo.pdo_GetCode (@inCode int)
RETURNS int AS
BEGIN
return @incode
END
$a[Code] = 'dbo.pdo_getcode(26050)';
$a[Description] = 'test';
$stmt = $dbh->prepare("insert into pdotest(Code,Description) VALUES
(:Code,:Description)");
$x = $stmt->execute($a);
$stmt = null;
$stmt = $dbh->prepare("insert into pdotest(Code,Description) VALUES
(dbo.pdo_getcode(26050),'test')");
$x = $stmt->execute();
$stmt = null;
$x = $dbh->exec("insert into pdotest(Code,Description) VALUES
(dbo.pdo_getcode(26050),'test')");
Expected result:
----------------
With the above code all three methods should insert a record
Actual result:
--------------
The first method fails with the replacement parameters and the other two
pass.
--
Edit bug report at http://bugs.php.net/?id=39143&edit=1
--
Try a CVS snapshot (PHP 4.4):
http://bugs.php.net/fix.php?id=39143&r=trysnapshot44
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=39143&r=trysnapshot52
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=39143&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=39143&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=39143&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=39143&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=39143&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=39143&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=39143&r=support
Expected behavior: http://bugs.php.net/fix.php?id=39143&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=39143&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=39143&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=39143&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=39143&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=39143&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=39143&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=39143&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=39143&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=39143&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=39143&r=mysqlcfg