Result
Result
Abstract base class for DBI result sets.
class Result implements \Hazaar\DBI\Interface\Result , \CountableImplements: Hazaar\DBI\Interface\Result, Countable
Provides common logic for handling result metadata, adapter association, model hydration, and utility methods for collating and grouping results. Implements Countable and ResultInterface.
Properties
meta
protected array $metaType: array
adapter
public Adapter $adapterType: Hazaar\DBI\Adapter
arrayColumns
protected array $arrayColumnsType: array
selectGroups
protected array $selectGroupsType: array
clobberDupNamedCols
When true, suppresses the automatic FETCH_NAMED upgrade fetch()/fetchAll() would otherwise
protected bool $clobberDupNamedColsType: bool
apply whenever this query has select groups -- see hasSelectGroups().
Methods
__construct
Construct a new result instance and associate it with an adapter.
public __construct(Adapter $adapter): voidParameters
| Parameter | Type | Description |
|---|---|---|
$adapter | Hazaar\DBI\Adapter | the database adapter instance |
__toString
Cast the result to a string, returning the SQL query string.
public __toString(): stringReturns: string
setAdapter
Set the database adapter for this result instance.
public setAdapter(Adapter $adapter): voidReturns: void
Parameters
| Parameter | Type | Description |
|---|---|---|
$adapter | Hazaar\DBI\Adapter | the database adapter to associate |
setSelectGroups
Set the select-group map used to reconstruct nested/grouped rows from a flat result.
public setSelectGroups(array $selectGroups): voidReturns: void
Parameters
| Parameter | Type | Description |
|---|---|---|
$selectGroups | array |
hasSelectGroups
Whether this query has any select groups configured (e.g. a grouped/nested
public hasSelectGroups(): boolReturns: bool
->select(['part' => 'p.', 'storage' => 's.']) call) -- fetch()/fetchAll() use this to decide whether they need FETCH_NAMED instead of FETCH_ASSOC to avoid silently collapsing same-named columns from different joined tables.
setClobberDupNamedCols
Suppress the automatic FETCH_NAMED upgrade fetch()/fetchAll() would otherwise apply for a
public setClobberDupNamedCols(bool $clobber): voidReturns: void
query with select groups, forcing plain FETCH_ASSOC (and its same-named-column-clobbering behaviour) instead -- for callers who know that's safe or desired for their specific case.
Parameters
| Parameter | Type | Description |
|---|---|---|
$clobber | bool |
count
Get the number of rows in the result set.
public count(): intReturns: int
collate
Collates a result into a simple key/value array.
public collate(int|string $indexColumn, int|string $valueColumn, int|string|null $groupColumn): arrayReturns: array
This is useful for generating SELECT lists directly from a resultset.
Parameters
| Parameter | Type | Description |
|---|---|---|
$indexColumn | int | string |
$valueColumn | int | string |
$groupColumn | int | string |
all
public all(): arrayReturns: array
fetchModel
Fetches a model instance of the specified class.
public fetchModel(string $modelClass): false|StructReturns: false|Hazaar\Model\Struct
Parameters
| Parameter | Type | Description |
|---|---|---|
$modelClass | string | the fully qualified class name of the model to fetch |
fetchAllModel
Fetches a collection of model instances of the specified class.
public fetchAllModel(string $modelClass, ?string $keyColumn): arrayReturns: array
Parameters
| Parameter | Type | Description |
|---|---|---|
$modelClass | string | the fully qualified class name of the model to fetch |
$keyColumn | string |
Generated by Hazaar API Doc Generator on Fri, 04 Sep 2026 23:32:16 +0000