class webCategory{
public $iWebCategory = 0;
public $sName = "";
public $sDescription = "";
public $iVisible = 0;
public $sInformation = "";
public function webCategory($iWebCategory){
$__sSql="SELECT *
FROM webcategorys
WHERE webcategory = $iWebCategory";
$__oRows=mysql_query($__sSql) OR DIE(mysql_error()."
".$__sSql);
if($aRow=mysql_fetch_array($__oRows,MYSQL_ASSOC)) {
$this->iWebCategory=$aRow['webcategory'];
$this->sName=$aRow['name'];
$this->sDescription=$aRow['description'];
$this->iVisible=$aRow['visible'];
$this->sInformation=$aRow['information'];
}else{
$this->iWebCategory=0;
$this->sName="";
$this->sDescription="";
$this->iVisible=0;
$this->sInformation="";
}
}
static function getwebCategorys(&$aSelect) {
$__aCategorys=array();
$__sWhere=" WHERE 1 ";
/*** LIMIT ***/
$__iOffset=isset($aSelect['iOffset'])?(int) $aSelect['iOffset']:0;
$__iRows=isset($aSelect['iRows'])?(int) $aSelect['iRows']:50;
/*** DESC/ASC ***/
$__sSort=isset($aSelect['sSort'])? $aSelect['sSort']:"DESC";
$__sSql="SELECT webcategory
FROM webcategorys
".$__sWhere."
ORDER BY webcategory ".$__sSort."
LIMIT ".$__iOffset.", ".$__iRows;
$__oRows=mysql_query($__sSql) OR DIE(mysql_error()."
".$__sSql);
while ($__aRow=mysql_fetch_array($__oRows,MYSQL_ASSOC)) {
$__aCategorys[]=new webCategory($__aRow['webcategory']);
}
return $__aCategorys;
}
/*** SAVE FUNCTION ***/
public function save(){
$sSql = "REPLACE webcategorys
SET webcategory = ".$this->iWebCategory.",
name = '".addslashes(stripslashes($this->sName))."',
description = '".addslashes(stripslashes($this->sDescription))."',
visible = '".$this->iVisible."',
information = '".addslashes(stripslashes($this->sInformation))."'";
mysql_query($sSql) or die(mysql_error()."
\n".$sSql);
if($this->iWebCategory == 0) $this->iWebCategory = mysql_insert_id();
return true;
}
/*** DELETE WEBCATEGORY ***/
public static function delCategory($uWebCategory) {
$sWebCategory=is_array($uWebCategory)?implode(",",$uWebCategory):(int) $uWebCategory;
$sSql="DELETE FROM webcategorys WHERE webcategory IN (".$sWebCategory.")";
mysql_query($sSql) or die(mysql_error()."
".$sSql);
}
}
?>
class webProduct{
public $iWebProduct = 0;
public $sName = "";
public $sDescription = "";
public $sImage = "";
public $iVisible = 0;
public $sInformation = "";
public $iWebCategory = 0;
public function webProduct($iWebProduct){
$__sSql="SELECT *
FROM webproducts
WHERE webproduct = $iWebProduct";
$__oRows=mysql_query($__sSql) OR DIE(mysql_error()."
".$__sSql);
if($aRow=mysql_fetch_array($__oRows,MYSQL_ASSOC)) {
$this->iWebProduct=$aRow['webproduct'];
$this->sName=$aRow['name'];
$this->sDescription=$aRow['description'];
$this->sImage=$aRow['image'];
$this->iVisible=$aRow['visible'];
$this->sInformation=$aRow['information'];
$this->iWebCategory=$aRow['webcategory'];
}else{
$this->iWebProduct=0;
$this->sName="";
$this->sDescription="";
$this->sImage="";
$this->iVisible=0;
$this->sInformation="";
$this->iWebCategory=0;
}
}
static function getwebProducts(&$aSelect) {
$__aCategorys=array();
$__sWhere=" WHERE 1";
/*** LIMIT ***/
$__iOffset=isset($aSelect['iOffset'])?(int) $aSelect['iOffset']:0;
$__iRows=isset($aSelect['iRows'])?(int) $aSelect['iRows']:50;
//*** WEBCATEGORY ***/
if(isset($aSelect['iWebCategory'])){
$__sWhere="WHERE webcategory IN (".$aSelect['iWebCategory'].")";
}
$__sSql="SELECT webproduct
FROM webproducts
".$__sWhere."
ORDER BY webproduct DESC
LIMIT ".$__iOffset.", ".$__iRows;
$__oRows=mysql_query($__sSql) OR DIE(mysql_error()."
".$__sSql);
while ($__aRow=mysql_fetch_array($__oRows,MYSQL_ASSOC)) {
$__aCategorys[]=new webProduct($__aRow['webproduct']);
}
return $__aCategorys;
}
static function getwebProductsVisible(&$aSelect) {
$__aCategorys=array();
$__sWhere=" WHERE 1 AND visible = '1'";
/*** LIMIT ***/
$__iOffset=isset($aSelect['iOffset'])?(int) $aSelect['iOffset']:0;
$__iRows=isset($aSelect['iRows'])?(int) $aSelect['iRows']:50;
//*** WEBCATEGORY ***/
if(isset($aSelect['iWebCategory'])){
$__sWhere="WHERE webcategory IN (".$aSelect['iWebCategory'].") AND visible = '1'";
}
$__sSql="SELECT webproduct
FROM webproducts
".$__sWhere."
ORDER BY webproduct DESC
LIMIT ".$__iOffset.", ".$__iRows;
$__oRows=mysql_query($__sSql) OR DIE(mysql_error()."
".$__sSql);
while ($__aRow=mysql_fetch_array($__oRows,MYSQL_ASSOC)) {
$__aCategorys[]=new webProduct($__aRow['webproduct']);
}
return $__aCategorys;
}
/*** SAVE FUNCTION ***/
public function save(){
$sSql = "REPLACE webproducts
SET webproduct = ".$this->iWebProduct.",
name = '".addslashes(stripslashes($this->sName))."',
description = '".addslashes(stripslashes($this->sDescription))."',
image = '".addslashes(stripslashes($this->sImage))."',
webcategory = '".$this->iWebCategory."',
visible = '".$this->iVisible."',
information = '".addslashes(stripslashes($this->sInformation))."'";
mysql_query($sSql) or die(mysql_error()."
\n".$sSql);
if($this->iWebProduct == 0) $this->iWebProduct = mysql_insert_id();
return true;
}
/*** DELETE WEBPRODUCT ***/
public static function delProduct($uWebProduct) {
$sWebCategory=is_array($uWebProduct)?implode(",",$uWebProduct):(int) $uWebProduct;
$sSql="DELETE FROM webproducts WHERE webproduct IN (".$sWebCategory.")";
mysql_query($sSql) or die(mysql_error()."
".$sSql);
}
}
?>