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
I want to cap the rows of CSV to certain number and I am not sure if I could safely stop the export process from a callback function, not using exit. Then I came up with throwing an exception to stop the function.
How would you think about this?
Here's example code.
$collection = new CallbackCollection($data, function($row) {
// apply custom format to the row
$row[1] = $row[1] . '!';
// if the data size exceeds a limit
if (...) {
throw new \Exception('ABORTED');
}
return $row;
});
$config = new ExporterConfig();
$exporter = new Exporter($config);
$exporter->export('php://stdout', $collection);
The text was updated successfully, but these errors were encountered:
Hi guys,
I want to cap the rows of CSV to certain number and I am not sure if I could safely stop the export process from a callback function, not using
exit
. Then I came up with throwing an exception to stop the function.How would you think about this?
Here's example code.
The text was updated successfully, but these errors were encountered: