mirror of
https://github.com/WordPress/WordPress.git
synced 2024-09-28 15:17:42 +02:00
wpdb::has_cap() from mdawaffe. fixes #7609
git-svn-id: http://svn.automattic.com/wordpress/trunk@8740 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
562fda59a7
commit
ed5372a6ab
@ -6,7 +6,7 @@ $charset_collate = '';
|
|||||||
// Declare these as global in case schema.php is included from a function.
|
// Declare these as global in case schema.php is included from a function.
|
||||||
global $wpdb, $wp_queries;
|
global $wpdb, $wp_queries;
|
||||||
|
|
||||||
if ( $wpdb->supports_collation() ) {
|
if ( $wpdb->has_cap( 'collation' ) ) {
|
||||||
if ( ! empty($wpdb->charset) )
|
if ( ! empty($wpdb->charset) )
|
||||||
$charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
|
$charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
|
||||||
if ( ! empty($wpdb->collate) )
|
if ( ! empty($wpdb->collate) )
|
||||||
|
@ -1046,7 +1046,7 @@ class WP_Query {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( !empty($q['category__not_in']) ) {
|
if ( !empty($q['category__not_in']) ) {
|
||||||
if ( $wpdb->supports_subqueries() ) {
|
if ( $wpdb->has_cap( 'subqueries' ) ) {
|
||||||
$cat_string = "'" . implode("', '", $q['category__not_in']) . "'";
|
$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) )";
|
$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 {
|
} else {
|
||||||
|
@ -332,7 +332,7 @@ class wpdb {
|
|||||||
|
|
||||||
$this->ready = true;
|
$this->ready = true;
|
||||||
|
|
||||||
if ( $this->supports_collation() ) {
|
if ( $this->has_cap( 'collation' ) ) {
|
||||||
$collation_query = '';
|
$collation_query = '';
|
||||||
if ( !empty($this->charset) ) {
|
if ( !empty($this->charset) ) {
|
||||||
$collation_query = "SET NAMES '{$this->charset}'";
|
$collation_query = "SET NAMES '{$this->charset}'";
|
||||||
@ -919,18 +919,27 @@ class wpdb {
|
|||||||
*/
|
*/
|
||||||
function supports_collation()
|
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.
|
* Generic function to determine if a database supports a particular feature
|
||||||
*
|
* @param string $db_cap the feature
|
||||||
* @since 2.7
|
* @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
|
||||||
* @return bool True if sub-queries are supported, false if version does not
|
|
||||||
*/
|
*/
|
||||||
function supports_subqueries() {
|
function has_cap( $db_cap ) {
|
||||||
return ( version_compare(mysql_get_server_info($this->dbh), '4.1.0', '>=') );
|
$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