wpdb::has_cap() from mdawaffe. fixes #7609
git-svn-id: https://develop.svn.wordpress.org/trunk@8740 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
e4dd07c75e
commit
9ab6c5d3f7
@ -6,7 +6,7 @@ $charset_collate = '';
|
||||
// Declare these as global in case schema.php is included from a function.
|
||||
global $wpdb, $wp_queries;
|
||||
|
||||
if ( $wpdb->supports_collation() ) {
|
||||
if ( $wpdb->has_cap( 'collation' ) ) {
|
||||
if ( ! empty($wpdb->charset) )
|
||||
$charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
|
||||
if ( ! empty($wpdb->collate) )
|
||||
|
@ -1046,7 +1046,7 @@ class WP_Query {
|
||||
}
|
||||
|
||||
if ( !empty($q['category__not_in']) ) {
|
||||
if ( $wpdb->supports_subqueries() ) {
|
||||
if ( $wpdb->has_cap( 'subqueries' ) ) {
|
||||
$cat_string = "'" . implode("', '", $q['category__not_in']) . "'";
|
||||
$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) )";
|
||||
} else {
|
||||
|
@ -332,7 +332,7 @@ class wpdb {
|
||||
|
||||
$this->ready = true;
|
||||
|
||||
if ( $this->supports_collation() ) {
|
||||
if ( $this->has_cap( 'collation' ) ) {
|
||||
$collation_query = '';
|
||||
if ( !empty($this->charset) ) {
|
||||
$collation_query = "SET NAMES '{$this->charset}'";
|
||||
@ -919,18 +919,27 @@ class wpdb {
|
||||
*/
|
||||
function supports_collation()
|
||||
{
|
||||
return ( version_compare($this->db_version(), '4.1.0', '>=') );
|
||||
return $this->has_cap( 'collation' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether of not the database version supports sub-queries.
|
||||
*
|
||||
* @since 2.7
|
||||
*
|
||||
* @return bool True if sub-queries are supported, false if version does not
|
||||
* Generic function to determine if a database supports a particular feature
|
||||
* @param string $db_cap the feature
|
||||
* @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)
|
||||
* @return bool
|
||||
*/
|
||||
function supports_subqueries() {
|
||||
return ( version_compare(mysql_get_server_info($this->dbh), '4.1.0', '>=') );
|
||||
function has_cap( $db_cap ) {
|
||||
$version = $this->db_version();
|
||||
|
||||
switch ( strtolower( $db_cap ) ) :
|
||||
case 'collation' : // @since 2.5.0
|
||||
case 'group_concat' : // @since 2.7
|
||||
case 'subqueries' : // @since 2.7
|
||||
return version_compare($version, '4.1', '>=');
|
||||
break;
|
||||
endswitch;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user