0

I have a php script, which looks up a translation for a given word:

$word = "the";
$db = new PDO("sqlite:words.sqlite");
$sth = $db->prepare("SELECT word, translation FROM words where word = ?");
$sth->execute(array($word]));

However, I wish to replace the string variable $word with an array called $words and look up the translations for a set of words. Can I execute a single statement to retrieve all of these values? How is this implemented in terms of code?

Baz
  • 12,713
  • 38
  • 145
  • 268
  • Have a look at this question: http://stackoverflow.com/questions/920353/php-pdo-can-i-bind-an-array-to-an-in-condition – vee Aug 14 '13 at 16:52

1 Answers1

0

Use the Mysql function IN in conjuction with your array. See this previous stack post: Can I bind an array to an IN() condition?

Community
  • 1
  • 1
kwolfe
  • 1,663
  • 3
  • 17
  • 27