Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

LLMS_Student_Query::sql_select()

Set up the SQL for the select statement.


Return Return

(string)


Top ↑

Source Source

File: includes/class.llms.student.query.php

	private function sql_select() {

		$selects = array();

		// Always select the ID.
		$selects[] = 'u.ID as id';

		// Always add the subqueries for enrollment status.
		$selects[] = "( {$this->sql_subquery( 'meta_value' )} ) AS status";

		// All the possible fields.
		$fields = array(
			'completed'        => "( {$this->sql_subquery( 'updated_date', '_is_complete' )} ) AS completed",
			'date'             => "( {$this->sql_subquery( 'updated_date' )} ) AS `date`",
			'last_name'        => 'm_last.meta_value AS last_name',
			'first_name'       => 'm_first.meta_value AS first_name',
			'email'            => 'u.user_email AS email',
			'registered'       => 'u.user_registered AS registered',
			'overall_progress' => 'CAST( m_o_p.meta_value AS decimal( 5, 2 ) ) AS overall_progress',
			'overall_grade'    => 'CAST( m_o_g.meta_value AS decimal( 5, 2 ) ) AS overall_grade',
		);

		// Add the fields to the array of fields to select.
		foreach ( $fields as $key => $statement ) {
			if ( $this->requires_field( $key ) ) {
				$selects[] = $statement;
			}
		}

		$sql = implode( ', ', $selects );
		$sql = $this->sql_select_columns( $sql );

		if ( $this->get( 'suppress_filters' ) ) {
			return $sql;
		}

		/**
		 * Filters the query SELECT clause
		 *
		 * @since 3.13.0
		 *
		 * @param string             $sql           The SELECT clause of the query.
		 * @param LLMS_Student_Query $student_query Instance of LLMS_Student_Query.
		 */
		return apply_filters( 'llms_student_query_select', $sql, $this );

	}


Top ↑

Changelog Changelog

Changelog
Version Description
5.10.0 Add a subquery for completed date.
4.10.2 Drop usage of this->get_filter( 'select' ) in favor of 'llms_student_query_select'. Use $this->sql_select_columns({columns}) to determine additional columns to select.
3.13.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.