March 2019
Intermediate to advanced
580 pages
15h 3m
English
Both of the previous queries return a StatementInterface, which is iterable. So, to access its data, we can do this:
foreach ($result as $record) { $id = $record->id; $team_id = $record->team_id; $name = $record->name; $data = $record->data;}
Each item in the loop is a stdClass, and their property names are the actual names of the columns returned, while their values are the column values.
Alternatively, the StatementInterface also has some fetcher methods that can prepare the results for us in different ways. These mostly come from the parent \PDOStatement class, which is native PHP. The simplest is fetchAll():
$records = $result->fetchAll();
This returns an array of stdClass objects, as we saw before, so it does all ...
Read now
Unlock full access