我使用Laravel DB :: select 从DB返回特定数据,
使用print_r($ result)
时,问题只有一行返回 $questions = DB::select('
select text
from question
where id in (?)
order by field(id,?)',
array($question_ids_list_str,$question_ids_list_str));
print_r($questions);
如何返回剩下的结果? 感谢,
答案 0 :(得分:2)
您可以尝试这样的事情:
$ids = array(1, 2, 3); // Pass the ids in whereIn clause
$questions = DB::table('question')
->whereIn('id', $ids)
->orderBy('id')
->get(array('text')); // Only get text field
答案 1 :(得分:0)
试试这个:
$questions = DB::select('
select text
from question
where id in (?)
order by field(id,?)',
array($question_ids_list_str,$question_ids_list_str));
foreach($questions as $question) {
echo $question;
}