FAQ
On 25 February 2016 at 13:31, Ryan Pallas wrote:
On Thu, Feb 25, 2016 at 11:20 AM, Marco Pivetta wrote:

Just adding to the use-cases: I really could've needed this the other day:


$records = array_map([MyRecord::class, '__construct'],
$db->someQuery()->fetchAll());

I used a named constructor instead, but this results with more internal
method calls:

$records = array_map([MyRecord::class, 'fromResultSetRow'],
$db->someQuery()->fetchAll());
If fetchAll is coming from PDO. then you could have simply done this:

$records = $db->someQuery()->fetchAll(MyRecord::class);
Not using PDO there.

Marco Pivetta

http://twitter.com/Ocramius

http://ocramius.github.com/

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 8 of 24 | next ›
Discussion Overview
groupphp-internals @
categoriesphp
postedFeb 25, '16 at 4:44p
activeMar 2, '16 at 6:19a
posts24
users10
websitephp.net

People

Translate

site design / logo © 2019 Grokbase