WordPress.org

Make WordPress Core


Ignore:
Timestamp:
10/04/2010 09:05:31 PM (10 years ago)
Author:
scribu
Message:

Move _wp_search_sql() into WP_Object_Query. Introduce WP_Comment_Search. See #15032

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/classes.php

    r15721 r15723  
    547547     * Populates the $meta_query property
    548548     *
    549      * @access private
     549     * @access protected
    550550     * @since 3.1.0
    551551     *
     
    571571     * Used internally to generate an SQL string for searching across multiple meta key = value pairs
    572572     *
    573      * @access private
     573     * @access protected
    574574     * @since 3.1.0
    575575     *
     
    621621
    622622        return array( $join, $where );
     623    }
     624
     625    /*
     626     * Used internally to generate an SQL string for searching across multiple columns
     627     *
     628     * @access protected
     629     * @since 3.1.0
     630     *
     631     * @param string $string
     632     * @param array $cols
     633     * @return string
     634     */
     635    function get_search_sql( $string, $cols ) {
     636        $string = esc_sql( $string );
     637
     638        $searches = array();
     639        foreach ( $cols as $col )
     640            $searches[] = "$col LIKE '%$string%'";
     641
     642        return ' AND (' . implode(' OR ', $searches) . ')';
    623643    }
    624644}
Note: See TracChangeset for help on using the changeset viewer.