ID: 41039 Updated by: [EMAIL PROTECTED] Reported By: emil at troxy dot net -Status: Open +Status: Bogus Bug Type: PDO related Operating System: Windows Server 2003 PHP Version: 5.2.1 New Comment:
Sorry, but your problem does not imply a bug in PHP itself. For a list of more appropriate places to ask for help using PHP, please visit http://www.php.net/support.php as this bug system is not the appropriate forum for asking support questions. Due to the volume of reports we can not explain in detail here why your report is not a bug. The support channels will be able to provide an explanation for you. Thank you for your interest in PHP. Previous Comments: ------------------------------------------------------------------------ [2007-04-10 15:08:14] emil at troxy dot net Description: ------------ I'm trying to do a simple SQL join using a prepared statement with a bound parameter as a part of the condition. The execution of the statement fails with an exception saying that I'm trying to do a compare on text, ntext or image data types, even though the tables don't contain these types. Reproduce code: --------------- CREATE TABLE [table1] ( [id] [int] NOT NULL ) ON [PRIMARY] CREATE TABLE [table2] ( [id] [int] NOT NULL ) ON [PRIMARY] INSERT INTO [table1] VALUES(1) INSERT INTO [table2] VALUES(1) <?php $dbh = new PDO('odbc:Driver={SQL Server}; Server=127.0.0.1; Uid=userid; Pwd=password; Database=database;'); $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $stmt = $dbh->prepare("SELECT t1.id, t2.id FROM table1 t1 INNER JOIN table2 t2 ON (t1.id = ?) AND (t2.id = 1)"); $stmt->bindValue(1, 1, PDO::PARAM_INT); $stmt->execute(); ?> Expected result: ---------------- The statement should execute without errors and return TRUE. Actual result: -------------- PHP Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 306 [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)' in D:\Website\pdo.php:8 Stack trace: #0 D:\Website\pdo.php(8): PDOStatement->execute() #1 {main} thrown in D:\Website\pdo.php on line 8 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=41039&edit=1