Make WordPress Core


Ignore:
Timestamp:
08/26/2008 11:57:48 PM (13 years ago)
Author:
ryan
Message:

wpdb::has_cap() from mdawaffe. fixes #7609

File:
1 edited

Legend:

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

    r8739 r8740  
    333333        $this->ready = true;
    334334
    335         if ( $this->supports_collation() ) {
     335        if ( $this->has_cap( 'collation' ) ) {
    336336            $collation_query = '';
    337337            if ( !empty($this->charset) ) {
     
    920920    function supports_collation()
    921921    {
    922         return ( version_compare($this->db_version(), '4.1.0', '>=') );
    923     }
    924 
    925     /**
    926      * Whether of not the database version supports sub-queries.
    927      *
    928      * @since 2.7
    929      *
    930      * @return bool True if sub-queries are supported, false if version does not
    931      */
    932     function supports_subqueries() {
    933         return ( version_compare(mysql_get_server_info($this->dbh), '4.1.0', '>=') );
     922        return $this->has_cap( 'collation' );
     923    }
     924
     925    /**
     926     * Generic function to determine if a database supports a particular feature
     927     * @param string $db_cap the feature
     928     * @param false|string|resource $dbh_or_table the databaese (the current database, the database housing the specified table, or the database of the mysql resource)
     929     * @return bool
     930     */
     931    function has_cap( $db_cap ) {
     932        $version = $this->db_version();
     933
     934        switch ( strtolower( $db_cap ) ) :
     935        case 'collation' :    // @since 2.5.0
     936        case 'group_concat' : // @since 2.7
     937        case 'subqueries' :   // @since 2.7
     938            return version_compare($version, '4.1', '>=');
     939            break;
     940        endswitch;
     941
     942        return false;
    934943    }
    935944
Note: See TracChangeset for help on using the changeset viewer.