ID:               36561
 User updated by:  travis at raybold dot com
-Summary:          PDO_ODBC/MSSQL does not work with bound params in
                   subquery
 Reported By:      travis at raybold dot com
-Status:           No Feedback
+Status:           Open
 Bug Type:         PDO related
 Operating System: Windows XP
 PHP Version:      5.1.2
 New Comment:

this bug is still happening, as "blohr at triad dot rr dot com" logged.


Previous Comments:
------------------------------------------------------------------------

[2007-07-18 01:00:00] php-bugs at lists dot php dot net

No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".

------------------------------------------------------------------------

[2007-07-10 17:20:05] blohr at triad dot rr dot com

I tried the code I posted previously with the snapshot you referenced.
Unfortunately, it didn't fix the problem. Here are the results:

> php -v
PHP 5.2.4-dev (cli) (built: Jul 10 2007 12:04:20) 
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies

> php mssql-odbc.php
array(4) {
  [0]=>
  string(5) "42000"
  [1]=>
  int(402)
  [2]=>
  string(166) "[Microsoft][SQL Native Client][SQL Server]The data types
varchar and text are incompatible in the equal to operator.
(SQLExecute[402] at ext\pdo_odbc\odbc_stmt.c:133)"
  [3]=>
  string(5) "42000"
}
array(4) {
  [0]=>
  string(5) "22018"
  [1]=>
  int(206)
  [2]=>
  string(141) "[Microsoft][SQL Native Client][SQL Server]Operand type
clash: text is incompatible with int (SQLExecute[206] at
ext\pdo_odbc\odbc_stmt.c:133)"
  [3]=>
  string(5) "22018"
}
array(4) {
  [0]=>
  string(5) "42000"
  [1]=>
  int(402)
  [2]=>
  string(166) "[Microsoft][SQL Native Client][SQL Server]The data types
varchar and text are incompatible in the equal to operator.
(SQLExecute[402] at ext\pdo_odbc\odbc_stmt.c:133)"
  [3]=>
  string(5) "42000"
}
array(4) {
  [0]=>
  string(5) "22018"
  [1]=>
  int(206)
  [2]=>
  string(141) "[Microsoft][SQL Native Client][SQL Server]Operand type
clash: text is incompatible with int (SQLExecute[206] at
ext\pdo_odbc\odbc_stmt.c:133)"
  [3]=>
  string(5) "22018"
}
array(4) {
  [0]=>
  string(5) "42000"
  [1]=>
  int(402)
  [2]=>
  string(166) "[Microsoft][SQL Native Client][SQL Server]The data types
varchar and text are incompatible in the equal to operator.
(SQLExecute[402] at ext\pdo_odbc\odbc_stmt.c:133)"
  [3]=>
  string(5) "42000"
}
array(4) {
  [0]=>
  string(5) "22018"
  [1]=>
  int(206)
  [2]=>
  string(141) "[Microsoft][SQL Native Client][SQL Server]Operand type
clash: text is incompatible with int (SQLExecute[206] at
ext\pdo_odbc\odbc_stmt.c:133)"
  [3]=>
  string(5) "22018"
}
array(4) {
  [0]=>
  string(5) "42000"
  [1]=>
  int(402)
  [2]=>
  string(166) "[Microsoft][SQL Native Client][SQL Server]The data types
varchar and text are incompatible in the equal to operator.
(SQLExecute[402] at ext\pdo_odbc\odbc_stmt.c:133)"
  [3]=>
  string(5) "42000"
}
array(4) {
  [0]=>
  string(5) "22018"
  [1]=>
  int(206)
  [2]=>
  string(141) "[Microsoft][SQL Native Client][SQL Server]Operand type
clash: text is incompatible with int (SQLExecute[206] at
ext\pdo_odbc\odbc_stmt.c:133)"
  [3]=>
  string(5) "22018"
}

------------------------------------------------------------------------

[2007-07-10 11:33:49] [EMAIL PROTECTED]

Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows (zip):
 
  http://snaps.php.net/win32/php5.2-win32-latest.zip

For Windows (installer):

  http://snaps.php.net/win32/php5.2-win32-installer-latest.msi



------------------------------------------------------------------------

[2007-06-22 17:50:11] blohr at triad dot rr dot com

This bug affects my app, too. I'm using PHP 5.2.3 on Windows XP Pro
SP2, under both IIS 5.1 and Apache 2.2, with SQL Server 2005 Express.

I don't know if it'll help or not, but here's some more reproduce code.
Just fix the PDO DSN string to something valid.

<?php
$db = new PDO("odbc:dsn=$odbcDsn;uid=$user;pwd=$pass");

$createTable = 
    'CREATE TABLE ##test (
        intCol int,
        textCol varchar(20)
    )';
$createTable2 =
    'CREATE TABLE ##test2 (
        intCol2 int,
        textCol2 varchar(20)
    )';
$db->exec($createTable);
$db->exec($createTable2);

$ins = $db->prepare('INSERT INTO ##test (intCol, textCol) VALUES (:i,
:t)');
$ins->execute(array('i'=>1, 't'=>'A String'));
$ins2 = $db->prepare('INSERT INTO ##test2 (intCol2, textCol2) VALUES
(:i, :t)');
$ins2->execute(array('i'=>1, 't'=>'Another String'));

$sel = $db->prepare('SELECT * FROM ##test WHERE intCol = (SELECT
intCol2 FROM ##test2 WHERE textCol2 = :t)');
$sel->execute(array('t'=>'Another String')) or
var_dump($sel->errorInfo());

$sel = $db->prepare('SELECT * FROM ##test WHERE intCol = (SELECT
intCol2 FROM ##test2 WHERE intCol2 = :i)');
$sel->execute(array('i'=>1)) or var_dump($sel->errorInfo());

$sel = $db->prepare('SELECT * FROM ##test WHERE intCol = (SELECT
intCol2 FROM ##test2 WHERE textCol2 = :t)');
$sel->bindValue('t', 'Another String');
$sel->execute() or var_dump($sel->errorInfo());

$sel = $db->prepare('SELECT * FROM ##test WHERE intCol = (SELECT
intCol2 FROM ##test2 WHERE intCol2 = :i)');
$sel->bindValue('i', 1);
$sel->execute() or var_dump($sel->errorInfo());

$sel = $db->prepare('SELECT * FROM ##test WHERE intCol = (SELECT
intCol2 FROM ##test2 WHERE textCol2 = :t)');
$sel->bindValue('t', 'Another String', PDO::PARAM_STR);
$sel->execute() or var_dump($sel->errorInfo());

$sel = $db->prepare('SELECT * FROM ##test WHERE intCol = (SELECT
intCol2 FROM ##test2 WHERE intCol2 = :i)');
$sel->bindValue('i', 1, PDO::PARAM_INT);
$sel->execute() or var_dump($sel->errorInfo());

$sel = $db->prepare('SELECT * FROM ##test WHERE intCol = (SELECT
intCol2 FROM ##test2 WHERE textCol2 = :t)');
$t = 'Another String';
$sel->bindParam('t', $t, PDO::PARAM_STR);
$sel->execute() or var_dump($sel->errorInfo());

$sel = $db->prepare('SELECT * FROM ##test WHERE intCol = (SELECT
intCol2 FROM ##test2 WHERE intCol2 = :i)');
$i = 1;
$sel->bindParam('i', $i, PDO::PARAM_INT);
$sel->execute() or var_dump($sel->errorInfo());
?>

------------------------------------------------------------------------

[2007-05-24 20:50:41] travis at raybold dot com

Hey Wez, I never saw the feedback til I stumbled on it today, and
clearly have been able to work around this, but it does keep stopping
me.

It happens exactly the same if I omit the PDO::PARAM_INT as the final
parameter.

I am still using the branched version you gave me... I'd be happy to
test with the latest if you think it might be fixed there.

--Travis

------------------------------------------------------------------------

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/36561

-- 
Edit this bug report at http://bugs.php.net/?id=36561&edit=1

Reply via email to