[nycphp-talk] PDO and Prepared Statements in MySQL when using LIKE [expr]
web dream works wdw
wdwtest at gmail.com
Mon Aug 6 01:11:12 EDT 2007
you can try for $$phpvar in the query. It might work.
$sth = $this->conn->prepare ("SELECT * FROM table WHERE column LIKE
On 8/5/07, Jakob Buchgraber <jakob.buchgraber at googlemail.com> wrote:
> 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);
> var_dump ($sth->fetchAll());
> 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
> New York PHP Community Talk Mailing List
> NYPHPCon 2006 Presentations Online
> Show Your Participation in New York PHP
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the talk