0

I have this query which works.

$query = "SELECT * FROM table WHERE item_id=? && (stage_token=? OR live_token=?)";
    
$stmt = $db->prepare($query); 
$stmt->bind_param("iss", $item, $token, $token);
$stmt->execute();
$result = $stmt->get_result(); 

I have to rewrite it for token parameter to be array. I am not sure how to use WHERE IN with OR.

$parameters = str_repeat('?,', count($token) - 1) . '?'; // placeholders
$types = str_repeat('s', count($token)); //types
tadman
  • 208,517
  • 23
  • 234
  • 262
Toniq
  • 4,492
  • 12
  • 50
  • 109
  • 1
    There's no `IN` clause in the query you've shown us. But in general terms, does this answer your question? [How can I bind an array of strings with a mysqli prepared statement?](https://stackoverflow.com/questions/17226762/how-can-i-bind-an-array-of-strings-with-a-mysqli-prepared-statement) – ADyson Jul 18 '23 at 14:57
  • SQL convention is to use `AND`. – tadman Jul 18 '23 at 15:03

0 Answers0