Pergunta

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];
Foi útil?

Solução

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

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

Outras dicas

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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top