PHP:PDO - 从表中选择多行

时间:2013-08-14 16:49:30

标签: php pdo sqlite

我有一个php脚本,它查找给定单词的翻译:

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

但是,我希望用一个名为$ words的数组替换字符串变量$ word,并查找一组单词的翻译。我可以执行单个语句来检索所有这些值吗?这是如何在代码方面实现的?

1 个答案:

答案 0 :(得分:0)

将Mysql函数IN与数组结合使用。请参阅此前一个堆叠帖子:Can I bind an array to an IN() condition?

相关问题