dg / dibi

Dibi - smart database abstraction layer
https://dibiphp.com
Other
487 stars 136 forks source link

Split query result by table #418

Open matejcik opened 2 years ago

matejcik commented 2 years ago

An example is worth a thousand works, it would be cool if this worked:

$result = $database->query('SELECT * FROM books INNER JOIN authors ON books.author_id = author.id');

foreach ($result as $row->byTable()) {
    echo $row->books->name . " by " . $row->authors->name;
}

It would be nice to cache, and pass into rowFactory / rowClass, the result of getResultColumns(). That way a custom rowFactory could accomplish this easily.