wpdb::has_cap PHP Method

has_cap() public method

Determine if a database supports a particular feature.
See also: wpdb::db_version()
Since: 2.7.0
public has_cap ( string $db_cap ) : boolean
$db_cap string The feature to check for.
return boolean
    public function has_cap($db_cap)
    {
        $version = $this->db_version();
        switch (strtolower($db_cap)) {
            case 'collation':
                // @since 2.5.0
            // @since 2.5.0
            case 'group_concat':
                // @since 2.7.0
            // @since 2.7.0
            case 'subqueries':
                // @since 2.7.0
                return version_compare($version, '4.1', '>=');
            case 'set_charset':
                return version_compare($version, '5.0.7', '>=');
        }
        return false;
    }

Usage Example

コード例 #1
0
ファイル: class.data.php プロジェクト: bchamberlain88/pavati
 /**
  * Initialize a new data object.
  */
 public function __construct($params = null)
 {
     global $wpdb;
     $this->db = $wpdb;
     // Set parameters.
     //
     if ($params != null && is_array($params)) {
         foreach ($params as $key => $value) {
             $this->{$key} = $value;
         }
     }
     // Collation
     //
     $collate = '';
     if ($this->db->has_cap('collation')) {
         if (!empty($this->db->charset)) {
             $collate .= "DEFAULT CHARACTER SET {$this->db->charset}";
         }
         if (!empty($this->db->collate)) {
             $collate .= " COLLATE {$this->db->collate}";
         }
     }
     $this->collate = $collate;
     // Legacy stuff - replace with data property below.
     //
     $this->info = array('table' => $this->db->prefix . 'store_locator', 'query' => array('selectthis' => 'SELECT %s FROM ' . $this->db->prefix . 'store_locator '));
     $this->add_filters();
     $this->set_properties();
 }
All Usage Examples Of wpdb::has_cap