MySQL Forums
Forum List  »  PHP

Re: How do you dynamically add additional variables to a PDO SQL query?
Posted by: Simon Lewis
Date: November 20, 2019 11:21AM

Let's say we want this query, but we want to also say "where town = 'london' and age = '35'.

But then we want to alter that so it is "Where town = 'london'" (don't care about age).

How do you build "$querypublish" to cater for that.
And how do you build "$resultpublish->execute" for the same purpose?

$querypublish = ("SELECT * FROM users WHERE gigid=:id");
$resultpublish = $pdo->prepare($querypublish);
$resultpublish->execute(array(':id' => $row->id));
while ($rowpublish = $resultpublish->fetch(PDO::FETCH_OBJ))


Options: ReplyQuote

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.