Automator_Get_Data::next_run_number( $recipe_id,  $user_id, bool $fetch_current = false )


Parameters Parameters

$recipe_id

(Required)

$user_id

(Required)

$fetch_current

(bool) (Optional)

Default value: false


Top ↑

Return Return

(int|null|string)


Source Source

File: src/core/lib/utilities/class-automator-get-data.php

	public function next_run_number( $recipe_id, $user_id, $fetch_current = false ) {
		if ( 0 !== absint( $user_id ) ) {
			global $wpdb;
			$run_number = $wpdb->get_var(
				$wpdb->prepare(
					"SELECT MAX(run_number)
						FROM {$wpdb->prefix}uap_recipe_log
						WHERE 1=1
						AND completed NOT IN (2,9)
						AND automator_recipe_id = %d
						AND user_id = %d",
					$recipe_id,
					$user_id
				)
			);

			if ( is_numeric( $run_number ) ) {
				if ( false === $fetch_current ) {
					$run_number ++;
				}

				return $run_number;
			}
		}

		return 1;
	}