}
$string=implode(" and ",$str);
$this->seekstr=$string;
$sql=sprintf("select * from %s where %s",$table,$string);
}
if(($rc=mysql_query($sql,$this->db))==false)
{echo "查询数据库时出错:".$sql;
exit();
}
$i=0;
while($this->buffer[$i]=mysql_fetch_array($rc))
{
$i++;
}
mysql_free_result($rc);
return $i;
}
function UpdateRecord($database,$table,$limitstr)
{mysql_select_db($database);
if($this->num==0)
exit("没有定义变量!");
for($i=0;$i<$this->num;$i++)
{if(is_string($this->value[$i]))
$ls[$i]="'".$this->value[$i]."'";
else
$ls[$i]=$this->value[$i];
$upstr[$i]=$this->name[$i]."=".$ls[$i];
}
$str=implode(",",$upstr);
$sql=sprintf("update %s set %s where %s",$table,$str,$limitstr);
if(mysql_query($sql,$this->db)==false)
{echo "修改数据时出错:".$sql;
exit();
}
}
function addtip($database,$table,$fileds,$limitstr="")
{//必须为整型字段
mysql_select_db($database);
if($limitstr!="")
$sql=sprintf("update %s set %s=%s+1 where %s",$table,$fileds,$fileds,$limitstr);
else
$sql=sprintf("update %s set %s=%s+1",$table,$fileds,$fileds);
if(mysql_query($sql,$this->db)==false)
{echo "修改数据时出错:".$sql;
exit();
}
}
function unaddtip($database,$table,$fileds,$limitstr="")
{
mysql_select_db($database);
if($limitstr!="")
$sql=sprintf("update %s set %s=%s-1 where %s",$table,$fileds,$fileds,$limitstr);
else
$sql=sprintf("update %s set %s=%s-1",$table,$fileds,$fileds);
if(mysql_query($sql,$this->db)==false)
{echo "修改数据时出错:".$sql;
exit();
}
}
function isempty($var,$china)
{if(trim($var)=="")
{
$reason="没有录入“".$china."”!";
exit($reason);
}
}
function GetResult()
{return $this->buffer;
}
function close()
{
mysql_close($this->db);
}
}
?>







