The value will be an array if the request has more than two fields.
X::dump($db->getKeyVal("SELECT name,id_group FROM table_users"));
/*
(array)[
"John" => 1,
"Michael" => 1,
"Barbara" => 1
]
X::dump($db->getKeyVal("SELECT name, surname, id FROM table_users WHERE id > 2 "));
/*
(array)[
"John" => [
"surname" => "Brown",
"id" => 3
],
"Michael" => [
"surname" => "Smith",
"id" => 4
]
]
function()
{
if ($r = $this->query(...\func_get_args())) {
if ($rows = $r->getRows()) {
return X::indexByFirstVal($rows);
}
return [];
}
return null;
}