<?php class clsdb { var $link=false; function Connn($host,$user,$pwd,$db) { $this->link = mysql_connect($host,$user,$pwd) or die("Could not connect : " . mysql_error()); mysql_select_db($db) or die("Could not select database"); $sql="set names 'gb2312'"; mysql_query($sql); } function Conn() { $this->link = mysql_connect("localhost","root","123") or die("Could not connect : " . mysql_error()); mysql_select_db("iwas") or die("Could not select database"); } function Exec($sql) { if ($this->link==false) { $this->Conn(); } $result=mysql_query($sql) or die("Query failed : " . mysql_error()); return $result; } function ExecCls($result) { mysql_free_result($result); } function Close() { if($this->link!==false) mysql_close($this->link); } } class clsdbex extends clsdb { function GetParam($namee) { $result=clsdb::Exec("select * from param where namee='".$namee."'"); $row = mysql_fetch_array($result); $vall=$row['vall']; clsdb::ExecCls($result); return $vall; www.shengfang.org } function SetParam($namee,$vall) { clsdb::Exec("update param set vall='".$vall."' where namee='".$namee."'"); } function GetParamAry($namee) www.shengfang.org { $resource = clsdb::Exec("select * from param where namee='".$namee."'"); if(mysql_num_rows($resource) > 0) { $result = array(); www.shengfang.org while ($row = mysql_fetch_array($resource)) { $result[] = $row["vall"]; }//end while return $result; }//end if return false; www.shengfang.org }//end function function GetCataAry($parent) { $resource = clsdb::Exec("select * from cata where parent".$parent); if(mysql_num_rows($resource) > 0) { $result = array(); while ($row = mysql_fetch_array($resource)) { $result[] = $row["namee"]; }//end while return $result; }//end if return false; www.shengfang.org }//end function function AddCata($namee,$parent) { $resource = clsdb::Exec("insert into cata (namee,parent) values('".$namee."',".$parent.")"); $resource=clsdb::Exec("select id from cata where parent=".$parent." and namee='".$namee."'"); $row = mysql_fetch_array($resource); return $row["id"]; }//end function www.shengfang.org function UpdateCata($nnamee,$onamee) { $resource = clsdb::Exec("update cata set namee='".$nnamee."' where namee='".$onamee."'"); }//end function function delCata($namee,$parent) { $resource = clsdb::Exec("delete from cata where namee='".$namee."'"); }//end function www.shengfang.org function GetCataID($namee,$parent) { //$resource=clsdb::Exec("select id from cata where parent=".$parent." and namee='".$namee."'"); $resource=clsdb::Exec("select id from cata where namee='".$namee."'"); $row = mysql_fetch_array($resource); $idd=$row["id"]; www.shengfang.org return $idd; } function GetCataName($idd) { //$resource=clsdb::Exec("select id from cata where parent=".$parent." and namee='".$namee."'"); $resource=clsdb::Exec("select namee from cata where id=".$idd); $row = mysql_fetch_array($resource); $namee=$row["namee"]; return $namee; } function GetCataParentID($namee,$parent) { //$resource=clsdb::Exec("select id from cata where parent=".$parent." and namee='".$namee."'"); $resource=clsdb::Exec("select parent from cata where namee='".$namee."'"); $row = mysql_fetch_array($resource); $idd=$row["parent"]; return $idd; } www.shengfang.org 字体:大 中 小 |