[nycphp-talk] PDO and Prepared Statements in MySQL when using LIKE [expr]
jakob.buchgraber at googlemail.com
Sun Aug 5 13:48:31 EDT 2007
I have some query with a LIKE expression e.g. "SELECT * FROM table WHERE
column LIKE "$phpvar%", but I would like to use prepared statements
instead of writing the variable directly into the query. So I write:
$sth = $this->conn->prepare ("SELECT * FROM table WHERE column LIKE
$sth->bindParam (":phpvar", $phpvar);
Here I get an empty result set when using prepared statements. However
when just using string concatenation and putting the variable directly
into the query it works fine.
Is this expected or a bug?
Sun Certified Programmer for the Java 2 Platform, Standard Edition 5.0
More information about the talk