Make WordPress Core

Changeset 8740


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

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

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/schema.php

    r8653 r8740  
    77global $wpdb, $wp_queries;
    88
    9 if ( $wpdb->supports_collation() ) {
     9if ( $wpdb->has_cap( 'collation' ) ) {
    1010        if ( ! empty($wpdb->charset) )
    1111                $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
  • trunk/wp-includes/query.php

    r8738 r8740  
    10471047
    10481048                if ( !empty($q['category__not_in']) ) {
    1049                         if ( $wpdb->supports_subqueries() ) {
     1049                        if ( $wpdb->has_cap( 'subqueries' ) ) {
    10501050                                $cat_string = "'" . implode("', '", $q['category__not_in']) . "'";
    10511051                                $whichcat .= " AND $wpdb->posts.ID NOT IN (SELECT $wpdb->term_relationships.object_id FROM $wpdb->term_relationships WHERE $wpdb->term_relationships.term_taxonomy_id IN ($cat_string) )";
  • 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.