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/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
Note: See TracChangeset for help on using the changeset viewer.