Make WordPress Core

Changeset 16351


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

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

Location:
trunk/wp-includes
Files:
3 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
  • trunk/wp-includes/comment.php

    r16149 r16351  
    342342        return $comments;
    343343    }
     344
     345    /*
     346     * Used internally to generate an SQL string for searching across multiple columns
     347     *
     348     * @access protected
     349     * @since 3.1.0
     350     *
     351     * @param string $string
     352     * @param array $cols
     353     * @return string
     354     */
     355    function get_search_sql( $string, $cols ) {
     356        $string = esc_sql( $string );
     357
     358        $searches = array();
     359        foreach ( $cols as $col )
     360            $searches[] = "$col LIKE '%$string%'";
     361
     362        return ' AND (' . implode(' OR ', $searches) . ')';
     363    }
    344364}
    345365
  • trunk/wp-includes/user.php

    r16286 r16351  
    527527    }
    528528
     529    /*
     530     * Used internally to generate an SQL string for searching across multiple columns
     531     *
     532     * @access protected
     533     * @since 3.1.0
     534     *
     535     * @param string $string
     536     * @param array $cols
     537     * @param bool $wild Whether to allow trailing wildcard searches. Default is false.
     538     * @return string
     539     */
     540    function get_search_sql( $string, $cols, $wild = false ) {
     541        $string = esc_sql( $string );
     542
     543        $searches = array();
     544        $wild_char = ( $wild ) ? '%' : '';
     545        foreach ( $cols as $col ) {
     546            if ( 'ID' == $col )
     547                $searches[] = "$col = '$string'";
     548            else
     549                $searches[] = "$col LIKE '$string$wild_char'";
     550        }
     551
     552        return ' AND (' . implode(' OR ', $searches) . ')';
     553    }
     554
    529555    /**
    530556     * Return the list of users
Note: See TracChangeset for help on using the changeset viewer.