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
Ejemplo n.º 1
0
 /**
  * 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();
 }
Ejemplo n.º 2
0
 /**
  * Initialize a new data object.
  *
  */
 public function SLPlus_Data($params = null)
 {
     global $wpdb;
     $this->db = $wpdb;
     // 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 '));
 }
Ejemplo n.º 3
0
 function has_cap($db_cap)
 {
     switch ($this->dbType) {
         case 'sqlite':
             switch (strtolower($db_cap)) {
                 case 'collation':
                     // @since 2.5.0
                 // @since 2.5.0
                 case 'group_concat':
                     // @since 2.7
                     return false;
                 case 'subqueries':
                     // @since 2.7
                     return true;
                     break;
                 default:
                     return false;
             }
             break;
         default:
             return parent::has_cap($db_cap);
     }
 }