Exemplo n.º 1
0
 /**
  * Connects to a database.
  * @return void
  * @throws Dibi\Exception
  */
 public function connect(array &$config)
 {
     Helpers::alias($config, 'options|UID', 'username');
     Helpers::alias($config, 'options|PWD', 'password');
     Helpers::alias($config, 'options|Database', 'database');
     Helpers::alias($config, 'options|CharacterSet', 'charset');
     if (isset($config['resource'])) {
         $this->connection = $config['resource'];
     } else {
         $options =& $config['options'];
         // Default values
         if (!isset($options['CharacterSet'])) {
             $options['CharacterSet'] = 'UTF-8';
         }
         $options['PWD'] = (string) $options['PWD'];
         $options['UID'] = (string) $options['UID'];
         $options['Database'] = (string) $options['Database'];
         $this->connection = sqlsrv_connect($config['host'], $options);
     }
     if (!is_resource($this->connection)) {
         $info = sqlsrv_errors();
         throw new Dibi\DriverException($info[0]['message'], $info[0]['code']);
     }
     $this->version = sqlsrv_server_info($this->connection)['SQLServerVersion'];
 }
Exemplo n.º 2
0
 public function server_version()
 {
     if ($this->lnk) {
         $info = sqlsrv_server_info($this->lnk);
         return $info['SQLServerVersion'];
     }
     return false;
 }
Exemplo n.º 3
0
 /**
  * {@inheritDoc}
  */
 function sql_server_info($raw = false, $use_cache = true)
 {
     global $cache;
     if (!$use_cache || empty($cache) || ($this->sql_server_version = $cache->get('mssql_version')) === false) {
         $arr_server_info = sqlsrv_server_info($this->db_connect_id);
         $this->sql_server_version = $arr_server_info['SQLServerVersion'];
         if (!empty($cache) && $use_cache) {
             $cache->put('mssql_version', $this->sql_server_version);
         }
     }
     if ($raw) {
         return $this->sql_server_version;
     }
     return $this->sql_server_version ? 'MSSQL<br />' . $this->sql_server_version : 'MSSQL';
 }
Exemplo n.º 4
0
 /**
  * DB Connect
  * this method is private
  * @param array $connection connection's value is db_hostname, db_database, db_userid, db_password
  * @return resource
  */
 function __connect($connection)
 {
     //sqlsrv_configure( 'WarningsReturnAsErrors', 0 );
     //sqlsrv_configure( 'LogSeverity', SQLSRV_LOG_SEVERITY_ALL );
     //sqlsrv_configure( 'LogSubsystems', SQLSRV_LOG_SYSTEM_ALL );
     $result = @sqlsrv_connect($connection['host'], array('Database' => $connection['database'], 'UID' => $connection['user'], 'PWD' => $connection['pass']));
     if (!$result) {
         $errors = print_r(sqlsrv_errors(), true);
         $this->setError(-1, 'database connect fail' . PHP_EOL . $errors);
         return;
     }
     $server_info = sqlsrv_server_info($result);
     $server_version = $server_info['SQLServerVersion'];
     if ($server_version && version_compare($server_version, '10', '<')) {
         $this->setError(-1, 'Rhymix requires Microsoft SQL Server 2008 or later. Current version is ' . $server_version);
         return;
     }
     return $result;
 }
 /**
  * Returns database server info array
  * @return array Array containing 'description', 'version' and 'database' (current db) info
  */
 public function get_server_info()
 {
     static $info;
     if (!$info) {
         $server_info = sqlsrv_server_info($this->sqlsrv);
         if ($server_info) {
             $info['description'] = $server_info['SQLServerName'];
             $info['version'] = $server_info['SQLServerVersion'];
             $info['database'] = $server_info['CurrentDatabase'];
         }
     }
     return $info;
 }
Exemplo n.º 6
0
 /**
  * @return string Version information from the database
  */
 public function getServerVersion()
 {
     $server_info = sqlsrv_server_info($this->mConn);
     $version = 'Error';
     if (isset($server_info['SQLServerVersion'])) {
         $version = $server_info['SQLServerVersion'];
     }
     return $version;
 }
Exemplo n.º 7
0
 /**
  * Database version number
  *
  * @return	string
  */
 public function version()
 {
     if (isset($this->data_cache['version'])) {
         return $this->data_cache['version'];
     } elseif (!$this->conn_id) {
         $this->initialize();
     }
     if (!$this->conn_id or ($info = sqlsrv_server_info($this->conn_id)) === FALSE) {
         return FALSE;
     }
     return $this->data_cache['version'] = $info['SQLServerVersion'];
 }
Exemplo n.º 8
0
 public function getVersion()
 {
     return sqlsrv_server_info($this->_connected);
 }
Exemplo n.º 9
0
 /**
  * Retrieve server version in PHP style
  *
  * @return string
  */
 public function getServerVersion()
 {
     $this->_connect();
     $serverInfo = sqlsrv_server_info($this->_connection);
     if ($serverInfo !== false) {
         return $serverInfo['SQLServerVersion'];
     }
     return null;
 }
Exemplo n.º 10
0
 /**
  * return version information about the server
  *
  * @param bool   $native  determines if the raw version string should be returned
  * @return mixed array/string with version information or MDB2 error object
  * @access public
  */
 function getServerVersion($native = false)
 {
     if ($this->connected_server_info) {
         $server_info = $this->connected_server_info;
     } else {
         $this->connect();
         $server_info = sqlsrv_server_info($this->connection);
     }
     // cache server_info
     $this->connected_server_info = $server_info;
     $version = $server_info['SQLServerVersion'];
     if (!$native) {
         if (preg_match('/(\\d+)\\.(\\d+)\\.(\\d+)/', $version, $tmp)) {
             $version = array('major' => $tmp[1], 'minor' => $tmp[2], 'patch' => $tmp[3], 'extra' => null, 'native' => $version);
         } else {
             $version = array('major' => null, 'minor' => null, 'patch' => null, 'extra' => null, 'native' => $version);
         }
     }
     return $version;
 }
 /**
  * Version number query string
  *
  * @access public
  * @return string
  */
 function _version()
 {
     $info = sqlsrv_server_info($this->conn_id);
     return sprintf("select '%s' as ver", $info['SQLServerVersion']);
 }
Exemplo n.º 12
0
 /**
  * @depends testConnection
  */
 public function testServer($con)
 {
     echo "\nServer info test.";
     // TODO: make better tests
     $this->assertTrue(is_array(sqlsrv_server_info($con)));
 }
Exemplo n.º 13
0
 /**
  * (non-PHPdoc)
  * @see DBManager::getDbInfo()
  * @return array
  */
 public function getDbInfo()
 {
     $info = array_merge(sqlsrv_client_info($this->database), sqlsrv_server_info($this->database));
     return $info;
 }
Exemplo n.º 14
0
function cs_sql_version($cs_file)
{
    global $cs_db;
    $sql_infos = array('data_free' => 0, 'data_size' => 0, 'index_size' => 0, 'tables' => 0, 'names' => array());
    $client = sqlsrv_client_info($cs_db['con']);
    $server = sqlsrv_server_info($cs_db['con']);
    $sql_infos['encoding'] = 'default';
    $sql_infos['type'] = 'Microsoft SQL Server (sqlsrv)';
    $sql_infos['client'] = $client['DriverVer'] . ' - ODBC ' . $client['DriverODBCVer'];
    $sql_infos['host'] = $server['SQLServerName'];
    $sql_infos['server'] = $server['SQLServerVersion'];
    return $sql_infos;
}
Exemplo n.º 15
0
 /**
  * Return the database version.
  *
  * @return string
  */
 public function version()
 {
     $server = sqlsrv_server_info($this->connection);
     return $server['SQLServerName'] . ': ' . $server['SQLServerVersion'];
 }
    /**
     * SQL Server check for server version
     *
     * @TODO Get this to actually check the server version.
     *
     * {@inheritDoc}
     */
    public function verifyServerVersion() {
        return array('result' => 'success','message' => $this->install->lexicon('sqlsrv_version_success',array('version' => '')));

        $handler = @sqlsrv_connect($this->install->settings->get('database_server'),$this->install->settings->get('database_user'),$this->install->settings->get('database_password'));
        $serverInfo = @sqlsrv_server_info($handler);
        $sqlsrvVersion = $serverInfo['SQLServerVersion'];
        $sqlsrvVersion = $this->_sanitizeVersion($sqlsrvVersion);
        if (empty($sqlsrvVersion)) {
            return array('result' => 'warning', 'message' => $this->install->lexicon('sqlsrv_version_server_nf'),'version' => $sqlsrvVersion);
        }

        $sqlsrv_ver_comp = version_compare($sqlsrvVersion,'10.50.0','>=');

        if (!$sqlsrv_ver_comp) { /* ancient driver warning */
            return array('result' => 'failure','message' => $this->install->lexicon('sqlsrv_version_fail',array('version' => $sqlsrvVersion)),'version' => $sqlsrvVersion);
        } else {
            return array('result' => 'success','message' => $this->install->lexicon('sqlsrv_version_success',array('version' => $sqlsrvVersion)),'version' => $sqlsrvVersion);
        }
    }
Exemplo n.º 17
0
 public function version()
 {
     if (!empty($this->connect)) {
         $info = sqlsrv_server_info($this->connect);
         return $info['SQLServerVersion'];
     } else {
         return false;
     }
 }
Exemplo n.º 18
0
 /**
  * Get the version of the database connector.
  *
  * @return  string  The database connector version.
  *
  * @since   12.1
  */
 public function getVersion()
 {
     $this->connect();
     $version = sqlsrv_server_info($this->connection);
     return $version['SQLServerVersion'];
 }
Exemplo n.º 19
0
 /**
 * 
 * @return multitype: Returns an associative array as described in the following table: (Key -- Value )
 * ==============================================
 * CurrentDatabase	 The connected-to database
 * ==============================================
 		SQLServerVersion	The SQL Server version.
 		SQLServerName	The name of the server.
 */
 public function getSQLServerInfo()
 {
     return sqlsrv_server_info($this->dbconnection);
 }
Exemplo n.º 20
0
 /**
  * {@inheritdoc}
  */
 public function getServerVersion()
 {
     $serverInfo = sqlsrv_server_info($this->conn);
     return $serverInfo['SQLServerVersion'];
 }
Exemplo n.º 21
0
 /**
  * (non-PHPdoc)
  * @see DBManager::getDbInfo()
  * @return array
  */
 public function getDbInfo()
 {
     $info = array_merge(sqlsrv_client_info(), sqlsrv_server_info());
     return $info;
 }
Exemplo n.º 22
0
 function ServerInfo()
 {
     global $ADODB_FETCH_MODE;
     if ($this->fetchMode === false) {
         $savem = $ADODB_FETCH_MODE;
         $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
     } else {
         $savem = $this->SetFetchMode(ADODB_FETCH_NUM);
     }
     $arrServerInfo = sqlsrv_server_info($this->_connectionID);
     $arr['description'] = $arrServerInfo['SQLServerName'] . ' connected to ' . $arrServerInfo['CurrentDatabase'];
     $arr['version'] = $arrServerInfo['SQLServerVersion'];
     //ADOConnection::_findvers($arr['description']);
     return $arr;
 }
Exemplo n.º 23
0
 /**
  * Database version number.
  *
  * @return string
  */
 public function version()
 {
     if (isset($this->data_cache['version'])) {
         return $this->data_cache['version'];
     }
     if (!$this->conn_id or ($info = sqlsrv_server_info($this->conn_id)) === false) {
         return false;
     }
     return $this->data_cache['version'] = $info['SQLServerVersion'];
 }