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:
ryan 2008-08-26 23:57:48 +00:00
parent 562fda59a7
commit ed5372a6ab
3 changed files with 20 additions and 11 deletions

View File

@ -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) )

View File

@ -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 {

View File

@ -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;
}
/**