我需要做一個簡單的查詢如何在查詢中使用準備好的語句與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 –