CI_DB_pdo_driver::version PHP Method

version() public method

Database version number
public version ( ) : string
return string
    public function version()
    {
        if (isset($this->data_cache['version'])) {
            return $this->data_cache['version'];
        }
        // Not all subdrivers support the getAttribute() method
        try {
            return $this->data_cache['version'] = $this->conn_id->getAttribute(PDO::ATTR_SERVER_VERSION);
        } catch (PDOException $e) {
            return parent::version();
        }
    }

Usage Example

 /**
  * Database version number
  *
  * @return    string
  */
 public function version()
 {
     if (isset($this->data_cache['version'])) {
         return $this->data_cache['version'];
     }
     $version_string = parent::version();
     if (preg_match('#Release\\s(?<version>\\d+(?:\\.\\d+)+)#', $version_string, $match)) {
         return $this->data_cache['version'] = $match[1];
     }
     return FALSE;
 }