0

i can explain with an example

$sorgu=$db->prepare("SELECT * FROM table WHERE name=:name1 OR name=:name2"); $sorgu->execute(['name1' => "John",'name2' => "Aydin"]); $cikti=$sorgu->fetchAll(PDO::FETCH_ASSOC); 

i can get what i want this way but should there be a more practical way? is there like this one way?

$answers=['John','Aydin']; $sorgu=$db->prepare("SELECT * FROM table WHERE name=:names"); $sorgu->execute(['names' => $answers]); $cikti=$sorgu->fetchAll(PDO::FETCH_ASSOC); 

i think this isn't work but i want to know there's should better way?

5
  • PHP - Using PDO with IN clause array Commented May 22, 2020 at 16:48
  • Thank You that's what i looking for Commented May 22, 2020 at 17:02
  • i am sorry, i need help. (products_category IN (:category)) it's not working only on category, if :category is 1 not problem but 1,22,23 it's not working Commented May 22, 2020 at 19:05
  • It's explained in the second link. Commented May 22, 2020 at 21:04
  • yep it's true i am sorry Commented May 26, 2020 at 19:33

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.