您可以这样进行:
$ids = array(1,5,18,25);// creates a string containing ?,?,? $clause = implode(',', array_fill(0, count($ids), '?'));$stmt = $mysqli->prepare('SELECt * FROM somewhere WHERe `id` IN (' . $clause . ') ORDER BY `name`;');call_user_func_array(array($stmt, 'bind_param'), $ids);$stmt->execute();// loop through results使用此方法,您将为每个id调用bind_param,并且已由mysql完成排序。



