ActionScheduler_DBStore::find_actions_by_claim_id
Retrieve the action IDs of action in a claim.
Method of the class: ActionScheduler_DBStore{}
No Hooks.
Returns
Int[].
Usage
$ActionScheduler_DBStore = new ActionScheduler_DBStore(); $ActionScheduler_DBStore->find_actions_by_claim_id( $claim_id );
- $claim_id(int) (required)
- Claim ID.
ActionScheduler_DBStore::find_actions_by_claim_id() ActionScheduler DBStore::find actions by claim id code WC 10.3.5
public function find_actions_by_claim_id( $claim_id ) {
/**
* Global.
*
* @var \wpdb $wpdb
*/
global $wpdb;
$action_ids = array();
$before_date = isset( $this->claim_before_date ) ? $this->claim_before_date : as_get_datetime_object();
$cut_off = $before_date->format( 'Y-m-d H:i:s' );
$sql = $wpdb->prepare(
"SELECT action_id, scheduled_date_gmt FROM {$wpdb->actionscheduler_actions} WHERE claim_id = %d ORDER BY priority ASC, attempts ASC, scheduled_date_gmt ASC, action_id ASC",
$claim_id
);
// Verify that the scheduled date for each action is within the expected bounds (in some unusual
// cases, we cannot depend on MySQL to honor all of the WHERE conditions we specify).
foreach ( $wpdb->get_results( $sql ) as $claimed_action ) { // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
if ( $claimed_action->scheduled_date_gmt <= $cut_off ) {
$action_ids[] = absint( $claimed_action->action_id );
}
}
return $action_ids;
}