public function &query($sql)
 {
     if ($this->echo_sql) {
         echo $sql;
     }
     $this->reset_vars();
     if ($this->connected === false) {
         $this->_debug_info('database connection has not been established!');
         return false;
     }
     global $g_db_log_file;
     if ($g_db_log_file) {
         $f_start = get_microtime();
     }
     $this->_qresult = mysql_query($sql, $this->_db);
     if ($g_db_log_file) {
         $f_length = get_microtime() - $f_start;
         $str = chr(13) . chr(10) . now() . " " . $_SERVER['SCRIPT_NAME'] . " execute sql: ({$f_length}ms)" . $sql;
         write_to_file($g_db_log_file, $str);
     }
     if ($this->_qresult === FALSE) {
         $this->_debug_info('fail to query db!' . $this->get_error() . ";query string = " . $sql);
         write_log('fail to execute sql!' . $this->get_error() . ";query string = " . $sql);
         return FALSE;
     } else {
         //get the recrod count
         $this->record_count = mysql_num_rows($this->_qresult);
         if ($this->_move_first() === false) {
             return $data_set;
         }
         do {
             $item = new database_row_item_class($this);
             $item->load_from_dataset();
             $this->data_set[] = $item;
         } while ($this->_move_next());
         return $this->data_set;
     }
 }
 public function &query($sql)
 {
     if ($this->echo_sql) {
         echo $sql;
     }
     $this->reset_vars();
     if ($this->connected === false) {
         $this->_debug_info('database connection has not been established!');
         return false;
     }
     global $g_db_log_file;
     if ($g_db_log_file) {
         $f_start = get_microtime();
     }
     $this->_qresult = sqlsrv_query($this->_db, $sql);
     if ($g_db_log_file) {
         $f_length = get_microtime() - $f_start;
         $str = chr(13) . chr(10) . now() . " " . $_SERVER['SCRIPT_NAME'] . " execute sql: ({$f_length}ms)" . $sql;
         write_to_file($g_db_log_file, $str);
     }
     if ($this->_qresult === FALSE) {
         $this->_debug_info('fail to query db!' . $this->get_error() . ";query string = " . $sql);
         return FALSE;
     } else {
         //get the recrod count
         $this->record_count = 0;
         while ($this->_aresult = sqlsrv_fetch_array($this->_qresult, SQLSRV_FETCH_ASSOC)) {
             $item = new database_row_item_class($this);
             $item->load_from_dataset($this->_db);
             $this->record_count++;
             $this->data_set[] = $item;
         }
         sqlsrv_free_stmt($this->_qresult);
         return $this->data_set;
     }
 }