Repository navigation
Type safe getters
Greg Bowler edited this page Mar 3, 2026
·
5 revisions
In this section, we will fetch single-column results as concrete PHP types.
fetchBool()fetchString()fetchInt()fetchFloat()fetchDateTime()
$username = $db->fetchString("user/getNameById", 42);
$score = $db->fetchFloat("score/getAverage", 42);
$createdAt = $db->fetchDateTime("user/getCreatedAt", 42);fetchAllBool()fetchAllString()fetchAllInt()fetchAllFloat()fetchAllDateTime()
$ids = $db->fetchAllInt("user/getAllIds");When we use fetch() or iterate fetchAll(), each row supports:
getString($column)getInt($column)getFloat($column)getBool($column)getDateTime($column)get($column)asArray()- property access such as
$row->name
getDateTime() accepts date strings and numeric unix timestamps.
Example code: example/03-type-safe-getters.php
PHP.GT/Database is a separately maintained component used by PHP.GT/WebEngine.