Ejemplo n.º 1
0
 /**
  * Execute a batch query
  * @return mixed A database resource if successful, FALSE if not.
  */
 function queryBatch($abort_on_error = true, $p_transaction_safe = false)
 {
     $this->_errorNum = 0;
     $this->_errorMsg = '';
     if ($p_transaction_safe) {
         $si = mssql_get_server_info($this->_resource);
         preg_match_all("/(\\d+)\\.(\\d+)\\.(\\d+)/i", $si, $m);
         if ($m[1] >= 4) {
             $this->_sql = 'START TRANSACTION;' . $this->_sql . '; COMMIT;';
         } else {
             if ($m[2] >= 23 && $m[3] >= 19) {
                 $this->_sql = 'BEGIN WORK;' . $this->_sql . '; COMMIT;';
             } else {
                 if ($m[2] >= 23 && $m[3] >= 17) {
                     $this->_sql = 'BEGIN;' . $this->_sql . '; COMMIT;';
                 }
             }
         }
     }
     $query_split = preg_split("/[;]+/", $this->_sql);
     $error = 0;
     foreach ($query_split as $command_line) {
         $command_line = trim($command_line);
         if ($command_line != '') {
             $this->_cursor = mssql_query($command_line, $this->_resource);
             if (!$this->_cursor) {
                 $error = 1;
                 $this->_errorNum .= mssql_errno($this->_resource) . ' ';
                 $this->_errorMsg .= mssql_error($this->_resource) . " SQL={$command_line} <br />";
                 if ($abort_on_error) {
                     return $this->_cursor;
                 }
             }
         }
     }
     return $error ? false : true;
 }
Ejemplo n.º 2
0
 /**
  * 获得数据库版本
  * @return string 版本号
  */
 function version()
 {
     return mssql_get_server_info();
 }
Ejemplo n.º 3
0
 /**
  * 获取服务器信息
  *
  * @return string 服务器信息
  */
 public function server_info()
 {
     return mssql_get_server_info();
 }