BP_Notifications_Notification::get_order_by_sql( array $args = array() )

Assemble the ORDER BY clause of a get() SQL statement.


Description Description

Used by BP_Notifications_Notification::get() to create its ORDER BY clause.


Top ↑

Parameters Parameters

$args

(array) (Optional) See BP_Notifications_Notification::get() for more details.

Default value: array()


Top ↑

Return Return

(string) ORDER BY clause.


Source Source

File: bp-notifications/classes/class-bp-notifications-notification.php

	protected static function get_order_by_sql( $args = array() ) {

		// Setup local variable.
		$conditions = array();
		$retval     = '';

		// Order by.
		if ( ! empty( $args['order_by'] ) ) {
			$order_by               = implode( ', ', (array) $args['order_by'] );
			$conditions['order_by'] = "{$order_by}";
		}

		// Sort order direction.
		if ( ! empty( $args['sort_order'] ) && in_array( $args['sort_order'], array( 'ASC', 'DESC' ) ) ) {
			$sort_order               = $args['sort_order'];
			$conditions['sort_order'] = "{$sort_order}";
		}

		// Custom ORDER BY.
		if ( ! empty( $conditions ) ) {
			$retval = 'ORDER BY ' . implode( ' ', $conditions );
		}

		return $retval;
	}


Top ↑

Changelog Changelog

Changelog
Version Description
1.9.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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