我需要做一个简单的查询如何在查询中使用准备好的语句与IN子句中PHP
$array_of_ids = array();
//poulate $array_of_ids, they don't come from another db but from Facebook
//so i can't use a subquery for the IN clause
$wpdb->prepare("SELECT id from table where id IN (%d, %d)", $array_of_ids [0], $array_of_ids [1]);
的问题是,如果我有数组中200个元素,什么是处理的正确方法这个吗?我必须用200 %d
手动建立查询吗?我需要这个查询,因为我必须使用facebook数据“同步”我的数据库,并且我必须检查我在数据库中的用户是否存在,更新存在的用户,插入新用户并删除那些不是我朋友的用户。
看看[这个问题] [1]不回答你的问题 [1]:http://stackoverflow.com/questions/327274/mysql-prepared-statements-with-a-variable-size-variable-list –