Form_List_Page_Handler::get_submission_count( int $form_id )

Gets the submission count for a given form ID.

Description

This method should be used since it makes a single aggregated API call to count submissions over each form.

See also

Parameters

$form_id

(int) (Required) Form ID.

Return

(int) Submission count for the form.

Source

File: src/db-objects/forms/form-list-page-handler.php

	protected function get_submission_count( $form_id ) {
		if ( ! isset( $this->submission_counts ) ) {
			$submission_manager = $this->form_manager->get_child_manager( 'submissions' );

			$results = $this->form_manager->db()->get_results( "SELECT form_id, COUNT( * ) AS num_submissions FROM %{$submission_manager->get_table_name()}% GROUP BY form_id" );

			$this->submission_counts = array();
			foreach ( $results as $row ) {
				$this->submission_counts[ $row->form_id ] = (int) $row->num_submissions;
			}
		}

		if ( ! isset( $this->submission_counts[ $form_id ] ) ) {
			return 0;
		}

		return $this->submission_counts[ $form_id ];
	}

Changelog

Changelog
Version Description
1.0.0 Introduced.