LLMS_Student_Query::preprare_query()

Prepare the SQL for the query.


Return Return

(string)


Top ↑

Source Source

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

		global $wpdb;

		$search_vars = array();

		if ( $this->get( 'search' ) ) {
			$search = '%' . $wpdb->esc_like( $this->get( 'search' ) ) . '%';
			$search_vars[] = $search;
			$search_vars[] = $search;
			$search_vars[] = $search;
		}

		$base_query = "SELECT {$this->sql_select()}
			FROM {$wpdb->users} AS u
			{$this->sql_joins()}
			{$this->sql_search()}
			{$this->sql_having()}";

		if ( $this->get( 'count_only' ) ) {
			$sql_query = "SELECT COUNT(*) AS total FROM ({$base_query}) as t;";

			if ( empty( $search_vars ) ) {
				return $sql_query;
			}

			// phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared
			return $wpdb->prepare( $sql_query, $search_vars );
			// phpcs:enable WordPress.DB.PreparedSQL.InterpolatedNotPrepared
		}

		if ( ! $this->get( 'no_found_rows' ) ) {
			$count_sql = "SELECT COUNT(*) FROM ({$base_query}) as t";
			if ( ! empty( $search_vars ) ) {

Top ↑

Changelog Changelog

Changelog
Version Description
4.10.2 Demands to $this->sql_select() to determine whether or not SQL_CALC_FOUND_ROWS statement is needed.
3.4.0
3.13.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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