Result
Query Result Extension.
Table of Contents
Methods
- result_keyvalue() : array<string|int, mixed>
- The result of the select is converted to an object where the specified column name is the key and the search result is the value.
Methods
result_keyvalue()
The result of the select is converted to an object where the specified column name is the key and the search result is the value.
public
result_keyvalue([string $column = 'id' ]) : array<string|int, mixed>
$rows = parent
->select('id,name')
->from('user')
->get()
->result_keyvalue('id');
var_export($rows);
// array (
// 1 => array (
// 'id' => 1,
// 'name' => 'Oliver',
// ),
// 2 => array (
// 'id' => 2,
// 'name' => 'Harry',
// ),
// )
Parameters
- $column : string = 'id'
-
(optional) Column Name. Default is "id".
Return values
array<string|int, mixed> —An object in which the column name is the key and the select result is the value.