WHERE clause confusion with PDO

Posted by Greg on Stack Overflow See other posts from Stack Overflow or by Greg
Published on 2010-06-13T00:48:00Z Indexed on 2010/06/13 0:52 UTC
Read the original article Hit count: 344

Filed under:
|
|

I'm having some trouble understanding how to use prepared statements, when you need to match one value against several columns at once.

In other words what instead of doing this:

$stmt = $dbh->prepare("SELECT * FROM REGISTRY where name = ?"); $stmt->bindParam(':name', $name);

I wanted to do this:

$stmt = $dbh->prepare("SELECT * FROM REGISTRY where firstname = ? or lastname = ?");

with both '?' representing the same string.

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql