You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Often we have custom assignment behaviour to do on top of bind(), for example setting the authorship data requires some custom code. It'd be nice to be able to pass in an anonymous function to deal with this assignment for each row. For example:
$result->bind('MyObject', function($row, $object) {
$object->authorship = new Authorship;
$object->create(new DateTimeImmutable('@' . $row->created_at), $row->created_by);
if ($row->updated_at) {
$object->update(new DateTimeImmutable('@' . $row->updated_at), $row->updated_by);
}
});
$result->bind(function($row) {
$object = new Object('something');
$object->authorship = new Authorship;
$object->create(new DateTimeImmutable('@' . $row->created_at), $row->created_by);
if ($row->updated_at) {
$object->update(new DateTimeImmutable('@' . $row->updated_at), $row->updated_by);
}
return $object
});
The text was updated successfully, but these errors were encountered:
Often we have custom assignment behaviour to do on top of
bind()
, for example setting the authorship data requires some custom code. It'd be nice to be able to pass in an anonymous function to deal with this assignment for each row. For example:The text was updated successfully, but these errors were encountered: