#36281 [Opn->Asn]: bindParam not working with LIKE '%:foo%'

From: Date: Sat, 04 Feb 2006 17:47:47 +0000
Subject: #36281 [Opn->Asn]: bindParam not working with LIKE '%:foo%'
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-92909@lists.php.net to get a copy of this message
 ID:               36281
 Updated by:       tony2001@php.net
 Reported By:      vendor at visv dot net
-Status:           Open
+Status:           Assigned
 Bug Type:         PDO related
 Operating System: Linux
 PHP Version:      5.1.2
-Assigned To:      
+Assigned To:      wez


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

[2006-02-04 18:21:16] vendor at visv dot net

No change nor improvement with
http://snaps.php.net/php5.1-latest.tar.gz on
Feb 4. 12:20PM

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

[2006-02-04 12:48:08] tony2001@php.net

Please try using this CVS snapshot:

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



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

[2006-02-04 05:35:05] vendor at visv dot net

Description:
------------
$q = "SELECT id, name FROM test WHERE name like '%:foo%';
$s = "carrot";

$dbh = new PDO('mysql:...', $user, $pass);

$sth = $dbh->prepare($q);
$sth->bindParam(':foo', $s);
$sth->execute()

while ($r = $sth->fetch()) {
    print_r($r);
}

the above does not work. Adding PDO::PARAM_STR, and the
length argument do not help matters.

simply embedding $s in place of :foo does work. It also
works fine if I leave off the "'%" and "%'" parts
and $s == the column value. It just seems bindParam()
cannot cope with the '% %' parts in the query.

I do not find similar in your bugtracking system, nor
in user supplied notes (currently there are none).

Thanks.


Reproduce code:
---------------
See description.



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


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


Thread (7 messages)

« previous php.bugs (#92909) next »