Make WordPress Core


Ignore:
Timestamp:
11/13/2010 06:18:45 PM (14 years ago)
Author:
scribu
Message:

Split get_search_sql(). See #15170. See #15032

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/class-wp-object-query.php

    r16267 r16351  
    7171        $qv['meta_query'] = $meta_query;
    7272    }
    73 
    74     /*
    75      * Used internally to generate an SQL string for searching across multiple columns
    76      *
    77      * @access protected
    78      * @since 3.1.0
    79      *
    80      * @param string $string
    81      * @param array $cols
    82      * @param bool $wild Whether to allow trailing wildcard searches. Default is false.
    83      * @return string
    84      */
    85     function get_search_sql( $string, $cols, $wild = false ) {
    86         $string = esc_sql( $string );
    87 
    88         $searches = array();
    89         $wild_char = ( $wild ) ? '%' : '';
    90         foreach ( $cols as $col ) {
    91             if ( 'ID' == $col )
    92                 $searches[] = "$col = '$string'";
    93             else
    94                 $searches[] = "$col LIKE '$string$wild_char'";
    95         }
    96 
    97         return ' AND (' . implode(' OR ', $searches) . ')';
    98     }
    9973}
    10074
Note: See TracChangeset for help on using the changeset viewer.