method getKeyVal documentation in bbn\Db\Languages\Sql

Return an array indexed on the first field of the request.

The value will be an array if the request has more than two fields.

Example

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; }

Return an array indexed on the first field of the request. BBN is a suite of PHP and JS libraries and VueJS components - all open-source! bbn.io, build applications, the quick way

This website uses cookies to ensure you get the best experience on our website.