Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




sanitize_sql_orderby [ WordPress Function ]

sanitize_sql_orderby ( $orderby )
Parameters:
  • (string) $orderby Order by string to be checked.
Returns:
  • (string|false) Returns the order by clause if it is a match, false otherwise.
Defined at:



Ensures a string is a valid SQL order by clause.

Accepts one or more columns, with or without ASC/DESC, and also accepts RAND().

Source


<?php
function sanitize_sql_orderby$orderby ){
    
preg_match('/^\s*([a-z0-9_]+(\s+(ASC|DESC))?(\s*,\s*|\s*$))+|^\s*RAND\(\s*\)\s*$/i'$orderby$obmatches);
    if ( !
$obmatches )
        return 
false;
    return 
$orderby;
}
?>

Examples [ wp-snippets.com ]

Top Google zoekresultaten

Meer ...

Gebruikersdiscussies [ wordpress.org ]

0 User Note(s)

Nog geen één. Wees de eerste!

Nieuw toevoegen ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics