00001 <?php
00002 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00003 # @title
00004 # MsSQL Query
00005 #
00006 # @description
00007
00011 # This file contains de query class definitions
00012 #
00013 # @see miolo/database.class,
00014 # miolo/mssql_connection.class,
00015 #
00016 # @topics db, business
00017 #
00018 # @created
00019 # 2001/08/14
00020 #
00021 # @organisation
00022 # MIOLO - Miolo Development Team - UNIVATES Centro Universitario
00023 # http://miolo.codigolivre.org.br
00024 #
00025 # @legal
00026 # CopyLeft (L) 2001-2002 UNIVATES, Lajeado/RS - Brasil
00027 # Licensed under GPL (see COPYING.TXT or FSF at www.fsf.org for
00028 # further details)
00029 #
00030 # @contributors
00031 # Vilson Cristiano Gartner [author] [vgartner@univates.br]
00032 # Thomas Spriestersbach [author] [ts@interact2000.com.br]
00033 # Clausius Duque G. Reis [clausius@ufv.br]
00034 #
00035 # @maintainers
00036 # Vilson Cristiano Gartner [author] [vgartner@univates.br]
00037 # Thomas Spriestersbach [author] [ts@interact2000.com.br]
00038 # Clausius Duque G. Reis [clausius@ufv.br]
00039 #
00040 # history: see miolo cvs.
00041 #
00042 # @id $Id: mssql_query.class,v 1.2 2003/09/12 11:18:00 clausius Exp $
00043 #---------------------------------------------------------------------
00044
00052 class MssqlQuery
00053 {
00057 var $conf;
00058
00062 var $conn;
00063
00067 var $sql;
00068
00072 var $result;
00073
00077 var $row;
00078
00082 var $error;
00083
00084
00094 function MssqlQuery($conf)
00095 {
00096 $this->conf = $conf;
00097 }
00098
00106 function GetError()
00107 {
00108 return $this->error;
00109 }
00110
00118 function Open()
00119 { global $MIOLO;
00120
00121 $MIOLO->LogSQL($this->sql,false,$this->conf);
00122
00123 $this->result = mssql_query($this->conn->id,$this->sql);
00124 $this->row = -1;
00125
00126 $this->error = mssql_get_last_message();;
00127
00128 return $this->result != null;
00129 }
00130
00138 function Close()
00139 {
00140 if ( $this->result != null )
00141 {
00142 mssql_free_result($this->result);
00143
00144 $this->result = null;
00145 }
00146 }
00147
00155 function MovePrev()
00156 {
00157 if ( $this->row >= 0 )
00158 {
00159 $this->row--;
00160
00161 return true;
00162 }
00163
00164 return false;
00165 }
00166
00174 function MoveNext()
00175 {
00176 if ( $this->row + 1 < $this->GetRowCount() )
00177 {
00178 $this->row++;
00179
00180 return true;
00181 }
00182
00183 return false;
00184 }
00185
00193 function GetRowCount()
00194 {
00195 if ($this->result != 0) {
00196 return mssql_num_rows($this->result);
00197 }
00198 }
00199
00207 function GetColumnCount()
00208 {
00209 return mssql_num_fields($this->result);
00210 }
00211
00221 function GetColumnName($col)
00222 {
00223 return mssql_field_name($this->result,$col-1);
00224 }
00225
00235 function GetValue($col)
00236 {
00237 return mssql_result($this->result,$this->row,$col-1);
00238 }
00239
00247 function GetRowValues()
00248 {
00249 return mssql_fetch_row($this->result,$this->row);
00250 }
00251
00261 function SetConnection($c)
00262 {
00263 $this->conn = $c;
00264 }
00265
00275 function SetSQL($sql)
00276 {
00277 $this->sql = $sql;
00278 }
00279 }
00280
00281 ?>