From:             travis at raybold dot com
Operating system: Windows XP
PHP version:      5.1.2
PHP Bug Type:     PDO related
Bug description:  PDO_ODBC/MSSQL does not work with bound params in subquery

Description:
------------
Connecting to a MSSQL database through PDO_ODBC, I prepare a statement
with a bound parameter inside of a subquery, and get a 42000 Syntax Error
when I execute it. 

The error indicates that it is trying to compare text. ntext or image
data, but the table consists solely of one integer field. Moving the bound
parameter outside of the subquery makes it work.

I am using PHP 5.1.2, MSSQL 2000, Windows XP, IIS6. 
Configure Line: cscript /nologo configure.js "--enable-snapshot-build"
"--with-gd=shared"



Reproduce code:
---------------
MSSQL:
CREATE TABLE zTest_TBL (
        TestID int NULL 
) 
INSERT INTO zTest_TBL (TestID) Values (1)

PHP:
<?
$iTestID=1;
$oConnection = new PDO($sDSN, $GLOBALS["sDatabase_Username"],
$GLOBALS["sDatabase_Password"]);
$oStatement = $oConnection->prepare('SELECT TestID FROM zTest_TBL WHERE
TestID IN (SELECT TestID FROM zTest_TBL WHERE TestID = :TestID)');
//$oStatement = $oConnection->prepare('SELECT TestID FROM zTest_TBL WHERE
TestID = :TestID AND TestID  IN (SELECT TestID FROM zTest_TBL )');
$oStatement->bindParam(':TestID', $iTestID,PDO::PARAM_INT );
$oStatement->execute() or print_r($oStatement->errorInfo());
foreach($oStatement as $aRow) {
  print_r($aRow);
}
?>

Expected result:
----------------
Array ( [TestID] => 1 [0] => 1 ) 


Actual result:
--------------
Array ( [0] => 42000 [1] => 306 [2] => [Microsoft][ODBC SQL Server
Driver][SQL Server]The text, ntext, and image data types cannot be
compared or sorted, except when using IS NULL or LIKE operator.
(SQLExecute[306] at ext\pdo_odbc\odbc_stmt.c:133) [3] => 42000 )

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

Reply via email to