문제

How can I get the INDEXED array result?

$qry1 = DB::select('name')->from('people')->execute();

$assoc_array = $qry1->as_array();
$object      = $qry1->as_object();

// $indexed_array = [...]

Only for learning purposes, thanks.

It's like:

$indexed_result[0]; // Name
// $indexed_result[1];
// $indexed_result[2];
도움이 되었습니까?

해결책

Do you want to get an array of names like array(0 => 'John', 1 => 'Sam')?

You should call $names = $gry1->as_array(NULL, 'name');

다른 팁

http://kohanaframework.org/3.3/guide/database/results#select-asobject-and-asassoc

The method as_assoc() will remove the object name and return the results set back to an associative array. Since this is the default, this method is seldom required.

So just do your execution.

But if you want only one row take a look at the current() method.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top