LLMS_Events::record_many( array[] $events = array() )
Record multiple events.
Description Description
Events are recorded with an SQL transaction. If any errors are encountered the transaction is rolled back (not events are recorded).
Parameters Parameters
- $events
-
(array[]) (Optional) Array of event hashes. See LLMS_Events::record() for hash description.
Default value: array()
Return Return
(LLMS_Event[]|WP_Error) Array of recorded events on success or WP_Error on failure.
Source Source
File: includes/class-llms-events.php
public function record_many( $events = array() ) {
global $wpdb;
$wpdb->query( 'START TRANSACTION' );
$recorded = array();
$errors = array();
foreach ( $events as $event ) {
$stat = $this->record( $event );
if ( is_wp_error( $stat ) ) {
$stat->add_data( $event );
$errors[] = $stat;
} else {
$recorded[] = $stat;
}
}
if ( count( $errors ) ) {
$wpdb->query( 'ROLLBACK' );
return new WP_Error( 'llms_events_record_many_errors', __( 'There was one or more errors encountered while recording the events.', 'lifterlms' ), $errors );
}
$wpdb->query( 'COMMIT' );
return $recorded;
}
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
| Version | Description |
|---|---|
| 3.36.0 | Introduced. |