Automator_DB_Handler_Triggers::add( int|null $user_id = null, int|null $trigger_id = null, int|null $recipe_id = null, bool $completed = false, int|null $recipe_log_id = null )


Parameters Parameters

$user_id

(int|null) (Optional)

Default value: null

$trigger_id

(int|null) (Optional)

Default value: null

$recipe_id

(int|null) (Optional)

Default value: null

$completed

(bool) (Optional)

Default value: false

$recipe_log_id

(int|null) (Optional)

Default value: null


Top ↑

Return Return

(int|null)


Source Source

File: src/core/lib/utilities/db/class-automator-db-handler-triggers.php

	public function add( int $user_id = null, int $trigger_id = null, int $recipe_id = null, bool $completed = false, int $recipe_log_id = null ) {
		if ( null === $trigger_id ) {
			return null;
		}
		if ( null === $user_id ) {
			return null;
		}
		if ( null === $recipe_id ) {
			return null;
		}

		global $wpdb;

		$table_name = $wpdb->prefix . Automator()->db->tables->trigger;

		$wpdb->insert(
			$table_name,
			array(
				'date_time'               => current_time( 'mysql' ),
				'user_id'                 => $user_id,
				'automator_trigger_id'    => $trigger_id,
				'automator_recipe_id'     => $recipe_id,
				'completed'               => $completed,
				'automator_recipe_log_id' => $recipe_log_id,
			),
			array(
				'%s',
				'%d',
				'%d',
				'%d',
				'%s',
				'%d',
			)
		);

		return $wpdb->insert_id;
	}