81 $this->UseLimit=
false;
83 $this->LastRow=array();
84 $this->CurrentRow=array();
93 function OpenDb($DBSystem,$DBUser=
"",$DBPasswd=
"")
97 $this->txtError=
'Database already open';
100 $this->SaveUser=$DBUser;
101 $this->SavePasswd=$DBPasswd;
102 if(($this->DbConn=mssql_connect($DBSystem,$DBUser,$DBPasswd))===FALSE)
105 $this->txtError=
"Error during connection to the server ".$DBSystem;
121 $this->txtError=
'No database open';
124 if(!mssql_select_db($DBname,$this->DbConn))
127 $this->txtError=
"I cannot select the db ".$DBname;
139 $this->UseLimit=FALSE;
143 $this->txtError=
'No database open';
146 if(($this->DbResult=mssql_query($sql,$this->DbConn))===
false)
149 $this->txtError=
"Error into sql statement. Sql string: ".$sql.
".Err:". mssql_get_last_message();
152 $this->CurrentRow[$this->DbResult]=0;
153 $this->LastQuery[$this->DbResult]=$sql;
154 return($this->DbResult);
169 if(($res=$this->
DbExecSql($select))===FALSE)
171 $this->UseLimit=TRUE;
173 $this->LimitStart=$start;
176 $this->LimitToEnd=$many;
179 $this->LimitToEnd=999999;
191 $nRows=mssql_num_rows($result);
208 return(mssql_num_fields($result));
220 $meta->name=mssql_field_name($result,$FieldNo);
221 $type=mssql_field_type($result,$FieldNo);
222 $meta->max_length=mssql_field_length($result,$FieldNo);
226 $meta->type=
'IGNORE';
245 $meta->type=
'DOUBLE';
266 $type=mssql_field_type($result,$FieldNo);
268 $txt=
'auto_increment';
283 if(!($es=mssql_free_result($result)))
284 $this->txtError=mssql_get_last_message();
285 $this->LastRow[$result]=array();
297 $this->txtError=
'No database open';
302 if($this->UseLimit&&!$this->LimitToEnd)
307 if(@mssql_data_seek($result,$this->CurrentRow[$result]))
309 $this->LastRow[$result]=mssql_fetch_array($result);
310 $this->CurrentRow[$result]++;
313 $this->LastRow[$result]=
false;
314 return($this->LastRow[$result]);
324 $this->txtError=
'No database open';
327 mssql_close($this->DbConn);
328 $this->Db_Open=
false;
346 foreach($row as $Key => $Value)
356 $fName.=
'['.$Key.
']';
357 $apice=$fieldsType[$Key][
'apice'];
358 $fValue.=$apice.$this->DBEscape($Value).$apice;
362 $OutText=
'('.$fName.
') VALUES ('.$fValue.
') ';
377 foreach($row as $Key => $Value)
379 if($c) $OutText.=
', ';
380 $apice=$fieldsType[$Key][
'apice'];
381 $OutText.=
'['.$Key.
'] = '.$apice.$this->DBEscape($Value).$apice.
' ';
396 return($FieldName.
' like \'%'.$pattern.
'%\'');
409 $quote=(bool)ini_get(
'magic_quotes_gpc');
411 $ret=str_replace(
"'",
"''",$value);
413 $ret=str_replace(
"\\",
"'",$value);
427 if($ValueType==
'DB_NUMBER')
428 return($FieldName.
' between '.$ValueFrom.
' and '.$ValueTo);
430 return($FieldName.
' between \''.$ValueFrom.
'\' and \
''.$ValueTo.
'\'');