Db record object | how to get in record objekt all present keys (field names)?

DB::select() returns the result in a collection (Kirby\Toolkit\Collection Object) and therein every record as an object (Kirby\Toolkit\Obj Object) in the form:

Kirby\Toolkit\Obj Object
(
    [project_id] => 100001383
    [project_type] => project
    [project_reference] => 
    [project_v_acronym] => MyProject202401
    [project_title] => My Project Title 2024.01
...

For a collection object there are some very handy methods to get more information about the collection object properties like $myCollectionObject-keys().

For the single record object these collection object methods do no exist.

What I want is to get from the record object the properties keys/names as an array: “project_id, project_type …”.
Is there a simple way to get those (all) object properties keys/keys in an array. The object method mySimpleObject->toArray() returns a complex array that can not be handled directly with the php function array_keys().

Many thanks in advance.

Does array_keys((array)$obj) work?

We’ve just implemented a new Obj::toKeys() method that you will be able to use from 4.5.0 onwards.