October 2017
Intermediate to advanced
566 pages
14h 31m
English
Both of the preceding queries return a StatementInterface, which is traversable. 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