bp_esc_sql_order

Sanitize an 'order' parameter for use in building SQL queries.

Description

(string) bp_esc_sql_order( (string) $order = '' ); 

Strings like DESC,, desc , desc. will be interpreted into DESC,. Everything else becomes ASC.

Returns (string)

The sanitized value 'DESC' or 'ASC'.

Parameters (1)

0. $order — Optional. (string) => ''
The order string, as passed to the SQL constructor.

Usage

  1. if ( !function_exists( 'bp_esc_sql_order' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-core/bp-core-functions.php'; 
  3.  
  4. // The 'order' string, as passed to the SQL constructor. 
  5. $order = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bp_esc_sql_order($order); 
  9.  

Defined (1)

The function is defined in the following location(s).

/bp-core/bp-core-functions.php  
  1. function bp_esc_sql_order( $order = '' ) { 
  2. $order = strtoupper( trim( $order ) ); 
  3. return 'DESC' === $order ? 'DESC' : 'ASC';