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.
Contents
Return Return
(string)
Source Source
File: includes/class.llms.student.query.php
/**
* Filters the part of the SQL query that performs the search.
*
* @since Unknown
*
* @param string $sql The SQL part that performs the search.
* @param LLMS_Student_Query $student_query Instance of LLMS_Student_Query.
*/
return apply_filters( 'llms_student_query_search', $sql, $this );
}
/**
* Set up the SQL for the select statement.
*
* @since 3.13.0
* @since 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.
* @since 5.10.0 Add a subquery for completed date.
*
* @return string
*/
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 ) ) {
Expand full source code Collapse full source code View on GitHub
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. |