PageVariation=3; $this->PagingQuery=""; $this->Query=""; $this->TotalRecords=0; $this->TotalPagingRecords=0; $this->TotalPages=0; $this->PageNumber=1; $this->PageSize=1000; $this->AffectedRows=0; //$this->RecordSetObj=NULL; //$this->Debug=MYSQL_DEBUG; $this->Reporttype=""; $this->Link=null; } function ExecuteQuery($SQL) { $Success = TRUE; if($this->Debug!=1) $Query = mysqli_query($this->Link, $SQL); else $Query = mysqli_query($this->Link, $SQL) or die(mysqli_error($this->Link)); if(!$Query) { $this->AffectedRows=0; $Success = FALSE; } else { $this->AffectedRows = mysqli_affected_rows($this->Link); } // print "
".$SQL."
"; return $Success; } // Performs a SELECT SQL query function SelectQuery($SQL) { $this->SetVariables(); $Success = NULL; if($this->Debug!=1) { $Query = mysqli_query($this->Link, $SQL) or die(mysqli_error($this->Link)); } else { $Query = mysqli_query($this->Link, $SQL) or die(mysqli_error($this->Link)); } if(!$Query) { $this->TotalRecords = 0; $Success = $Query; } else { $this->TotalRecords = mysqli_num_rows($Query); } if($this->TotalRecords == 0) { $this->TotalRecords = 0; $Success = $Query; } else { //$this->RecordSetObj=$Query; $Success=$Query; } //print "
".$SQL."
"; //print $this->TotalRecords."AAAAADS" ; return $Success; } function PagingLinks() { $this->SetPagingFormat(); $PageingStr=$this->PagingFormat["Table"].$this->MovePrevious().$this->MoveNext().$this->PagingFormat["/Table"]; return $PageingStr; } function MovePrevious() { if($this->PageNumber>1) { $regexp="/()/s"; $pagelink=preg_replace($regexp,($this->PageNumber-1),$this->PagingFormat["Link"]); $regexp="/()/s"; $pagelink=preg_replace($regexp,"Move Previous",$pagelink); $move_pre=$this->PagingFormat["TD"].$pagelink."<<".$this->PagingFormat["/Link"].$this->PagingFormat["/TD"]; } else { $move_pre=" "; } return $move_pre; } function GetQueryStrings($tar) { Global $PHP_SELF,$HTTP_GET_VARS; unset($HTTP_GET_VARS[$tar]); reset($HTTP_GET_VARS); while (list ($key, $val) = each ($HTTP_GET_VARS)) { if($str=="") $str=$key."=".$val; else$str=$str."&".$key."=".$val; } $str=$PHP_SELF."?".$str; return $str; } function SetPagingFormat() { $this->PagingLink=$this->GetQueryStrings("_Page")."&_Page=";//set query string as it is $this->PagingFormat["Table"]=""; $this->PagingFormat["/Table"]="
"; $this->PagingFormat["TD"]=""; $this->PagingFormat["/TD"]=""; $this->PagingFormat["TD1"]=""; $this->PagingFormat["/TD1"]=""; $this->PagingFormat["Link"]="

PagingLink.""."\" onmouseover=\"return escape('')\">"; $this->PagingFormat["/Link"]="

"; $this->PagingFormat["Link1"]="

"; $this->PagingFormat["/Link1"]="

"; } function MoveNext() { $PagingLinksPrivious=""; $PagingLinksNext=""; $PageCount=0; $PriviousPaging=0; $NextPaging=0; $rset=mysqli_query($this->Link, $this->PagingQuery) or die(mysqli_error($this->Link)); if(mysqli_num_rows($rset)>0) { if($this->IsRowCountPaging==true) { $RowCount=mysqli_num_rows($rset); } else { $rs=mysqli_fetch_row($rset); $RowCount=$rs[0]; } //print "Records :- " . $this->RecordCount."
"; //print "Page Size :- " . $this->PageSize."
"; $this->TotalPagingRecords=$RowCount; (($RowCount % $this->PageSize)>0) ? $PageCount=floor($RowCount/$this->PageSize)+1 : $PageCount=floor($RowCount/$this->PageSize); //print "Page Count:- " . $PageCount."
"; //print "Current Page :- " . $this->PageNumber."
"; ($this->PageNumber-$this->PageVariation) > 0 ? $PriviousPaging=$this->PageNumber-$this->PageVariation : $PriviousPaging=1; $this->TotalPages=$PageCount; if($PageCount>1) { for($i=$PriviousPaging;$i<$this->PageNumber;$i++) { //print $i; $regexp="/()/s"; $pagelink=preg_replace($regexp,$i,$this->PagingFormat["Link"]); $regexp="/()/s"; $pagelink=preg_replace($regexp,"Page ".$i,$pagelink); $PagingLinksPrivious=$PagingLinksPrivious.$this->PagingFormat["TD"].$pagelink.$i."
".$this->PagingFormat["/Link"].$this->PagingFormat["/TD"]; } //print $PagingLinksPrivious; $PageCount > ($this->PageVariation+$this->PageNumber) ? $NextPaging=$this->PageVariation+$this->PageNumber : $NextPaging=$PageCount; for($i=$this->PageNumber;$i<=$NextPaging;$i++) { if($i==$this->PageNumber){ $PagingLinksNext=$PagingLinksNext.$this->PagingFormat["TD1"].$this->PagingFormat["Link1"]."$i".$this->PagingFormat["/Link1"].$this->PagingFormat["/TD1"]; } else { $regexp="/()/s"; $pagelink=preg_replace($regexp,$i,$this->PagingFormat["Link"]); $regexp="/()/s"; $pagelink=preg_replace($regexp,"Page ".$i,$pagelink); $PagingLinksNext=$PagingLinksNext.$this->PagingFormat["TD"].$pagelink.$i."".$this->PagingFormat["/Link"].$this->PagingFormat["/TD"]; } } //print $PagingLinksNext; $Resultset=$PagingLinksPrivious.$PagingLinksNext; } } else { $Resultset="false"; } if($this->PageNumber<$PageCount) { $regexp="/()/s"; $pagelink=preg_replace($regexp,($this->PageNumber+1),$this->PagingFormat["Link"]); $regexp="/()/s"; $pagelink=preg_replace($regexp,"Move Next",$pagelink); $Resultset=$Resultset.$this->PagingFormat["TD"].$pagelink.">>".$this->PagingFormat["/Link"].$this->PagingFormat["/TD"]; } else { $Resultset=$Resultset." "; } return $Resultset; } ///////////////////////////// function PageSizes() { $pages[]=2; $pages[]=4; $pages[]=6; $pages[]=8; $pages[]=10; $pages[]=12; $pages[]=15; $pages[]=20; $pages[]=25; $pages[]=50; $pages[]=100; $pages[]=200; $pages[]=300; $pages[]=400; $pages[]=500; $pages[]=600; $pages[]=700; $pages[]=800; $pages[]=900; $pages[]=1000; $pages[]=1000000; $tmp=$this->GetQueryStrings("_PageSize")."&_PageSize="; $ReturnStr=""; return $ReturnStr; } function CurrentPaging() { return "Pages ".$this->PageNumber." of ".$this->TotalPages; } function SetVariables() { $this->ErrorMessage=""; $this->EOF=NULL; $this->Query=""; $this->PagingQuery; $this->TotalRecords=0; $this->TotalPagingRecords=0; $this->TotalPages=0; $this->AffectedRows=0; //$this->RecordSetObj=NULL; } function SetErrorMessage() { $this->ErrorMessage = 'Error ' . mysqli_errno() . ': ' . mysqli_error($this->Link); } } ?>Database(); } function insertRec() { $Query ="INSERT INTO `zing_eatery_locations` (loc_id,client_id,loc_name,loc_cuisine,loc_slogan,loc_description,loc_dateopened,loc_name_genmgr,loc_name_asstmgr,loc_address1,loc_address2,loc_city,loc_state,loc_zip,loc_phone,loc_phone2,loc_fax,loc_email,loc_website,loc_neighborhood,loc_cross_st,loc_maplink,loc_latitude,loc_longitude,loc_pricerange,loc_taxrate,loc_payoptions,loc_dineoptions,loc_min_delivery,loc_parties,loc_parking,loc_features,loc_reservations,loc_orderonline,loc_smoking,loc_logo,loc_photo,loc_stylesheet,loc_pizza,loc_bar,loc_online_orderoptions,loc_del_fee,loc_order_message,loc_aboutus) values ('$this->loc_id','$this->client_id','$this->loc_name','$this->loc_cuisine','$this->loc_slogan','$this->loc_description','$this->loc_dateopened','$this->loc_name_genmgr','$this->loc_name_asstmgr','$this->loc_address1','$this->loc_address2','$this->loc_city','$this->loc_state','$this->loc_zip','$this->loc_phone','$this->loc_phone2','$this->loc_fax','$this->loc_email','$this->loc_website','$this->loc_neighborhood','$this->loc_cross_st', '$this->loc_maplink','$this->loc_latitude','$this->loc_longitude','$this->loc_pricerange','$this->loc_taxrate','$this->loc_payoptions','$this->loc_dineoptions','$this->loc_min_delivery','$this->loc_parties','$this->loc_parking','$this->loc_features','$this->loc_reservations','$this->loc_orderonline','$this->loc_smoking','$this->loc_logo','$this->loc_photo','$this->loc_stylesheet','$this->loc_pizza','$this->loc_bar','$this->loc_online_orderoptions','$this->loc_del_fee','$this->loc_order_message','$this->loc_aboutus','$this->loc_specials')" ; $this->ExecuteQuery($Query); return $this->AffectedRows; } //----- To set the class propertise to update single record function setupdate() { $success=false; $Query="select * from `zing_eatery_locations` where loc_id=".$this->loc_id; $rset=$this->SelectQuery($Query); if($rs=mysqli_fetch_object($rset)) { $success=true; $this->loc_id=$rs->loc_id; $this->client_id=$rs->client_id; $this->loc_name=$rs->loc_name; $this->loc_cuisine=$rs->loc_cuisine; $this->loc_slogan=$rs->loc_slogan; $this->loc_description=$rs->loc_description; $this->loc_dateopened=$rs->loc_dateopened; $this->loc_name_genmgr=$rs->loc_name_genmgr; $this->loc_name_asstmgr=$rs->loc_name_asstmgr; $this->loc_address1=$rs->loc_address1; $this->loc_address2=$rs->loc_address2; $this->loc_city=$rs->loc_city; $this->loc_state=$rs->loc_state; $this->loc_zip=$rs->loc_zip; $this->loc_phone=$rs->loc_phone; $this->loc_phone2=$rs->loc_phone2; $this->loc_fax=$rs->loc_fax; $this->loc_email=$rs->loc_email; $this->loc_website=$rs->loc_website; $this->loc_neighborhood=$rs->loc_neighborhood; $this->loc_cross_st=$rs->loc_cross_st; $this->loc_maplink=$rs->loc_maplink; $this->loc_latitude=$rs->loc_latitude; $this->loc_longitude=$rs->loc_longitude; $this->loc_pricerange=$rs->loc_pricerange; $this->loc_taxrate=$rs->loc_taxrate; $this->loc_payoptions=$rs->loc_payoptions; $this->loc_dineoptions=$rs->loc_dineoptions; $this->loc_min_delivery=$rs->loc_min_delivery; $this->loc_parties=$rs->loc_parties; $this->loc_parking=$rs->loc_parking; $this->loc_features=$rs->loc_features; $this->loc_reservations=$rs->loc_reservations; $this->loc_orderonline=$rs->loc_orderonline; $this->loc_smoking=$rs->loc_smoking; $this->loc_logo=$rs->loc_logo; $this->loc_photo=$rs->loc_photo; $this->loc_stylesheet=$rs->loc_stylesheet; $this->loc_pizza=$rs->loc_pizza; $this->loc_bar=$rs->loc_bar; $this->loc_online_orderoptions=$rs->loc_online_orderoptions; $this->loc_del_fee=$rs->loc_del_fee; $this->loc_order_message=$rs->loc_order_message; $this->loc_aboutus=$rs->loc_aboutus; $this->loc_specials=$rs->loc_specials; } return $success; } function updateRec() { //----Update one record. its only work on unique field $Query="update `zing_eatery_locations` set `loc_id`='$this->loc_id', `client_id`='$this->client_id', `loc_name`='$this->loc_name', `loc_cuisine`='$this->loc_cuisine', `loc_slogan`='$this->loc_slogan', `loc_description`='$this->loc_description', `loc_dateopened`='$this->loc_dateopened', `loc_name_genmgr`='$this->loc_name_genmgr', `loc_name_asstmgr`='$this->loc_name_asstmgr', `loc_address1`='$this->loc_address1', `loc_address2`='$this->loc_address2', `loc_city`='$this->loc_city', `loc_state`='$this->loc_state', `loc_zip`='$this->loc_zip', `loc_phone`='$this->loc_phone', `loc_phone2`='$this->loc_phone2', `loc_fax`='$this->loc_fax', `loc_email`='$this->loc_email', `loc_website`='$this->loc_website', `loc_neighborhood`='$this->loc_neighborhood', `loc_cross_st`='$this->loc_cross_st', `loc_maplink`='$this->loc_maplink', `loc_latitude`='$this->loc_latitude', `loc_longitude`='$this->loc_longitude', `loc_pricerange`='$this->loc_pricerange', `loc_taxrate`='$this->loc_taxrate', `loc_payoptions`='$this->loc_payoptions', `loc_dineoptions`='$this->loc_dineoptions', `loc_min_delivery`='$this->loc_min_delivery', `loc_parties`='$this->loc_parties', `loc_parking`='$this->loc_parking', `loc_features`='$this->loc_features', `loc_reservations`='$this->loc_reservations', `loc_orderonline`='$this->loc_orderonline', `loc_smoking`='$this->loc_smoking', `loc_logo`='$this->loc_logo', `loc_photo`='$this->loc_photo', `loc_stylesheet`='$this->loc_stylesheet', `loc_pizza`='$this->loc_pizza', `loc_bar`='$this->loc_bar', `loc_online_orderoptions`='$this->loc_online_orderoptions', `loc_del_fee`='$this->loc_del_fee', `loc_order_message`='$this->loc_order_message', `loc_aboutus`='$this->loc_aboutus', `loc_specials`='$this->loc_specials' where loc_id=".$this->loc_id; echo $Query; $this->ExecuteQuery($Query); return $this->AffectedRows; } //---Delte one record function DeleteRec() { $Query = "Delete from `zing_eatery_locations` where loc_id='$this->loc_id'"; $this->ExecuteQuery($Query); return $this->AffectedRows; } //----- Function to delete Multiple Records function DeleteRecords() { if($this->Reporttype=="allrecord") { $Query = "Delete from `zing_eatery_locations` "; } //print $Query; $this->ExecuteQuery($Query); return $this->AffectedRows; } //----- Function to delete Multiple Records function UpdateRecords() { //print $Query; $this->ExecuteQuery($Query); return $this->AffectedRows; } function FetchRecords() { //---- Fix the records limits---- $this->LimitFrom=($this->PageNumber-1) * $this->PageSize; $this->LimitTo=$this->PageNumber * $this->PageSize; //---- Build query with limit or without limit. join query as well if($this->Reporttype=="allrecord") { $Query = "select * from `zing_eatery_locations` order by loc_id limit ".$this->LimitFrom.",".$this->PageSize; $this->PagingQuery="select count(*) from zing_eatery_locations"; } if($this->Reporttype=="Fetch_Single_Records_By_Location_ID") { //$Query = "SELECT * FROM zing_eatery_locations WHERE loc_id='$this->loc_id'"; $Query = "SELECT l.*, h.*,c.*,l.loc_id as loc_id FROM zing_eatery_locations AS l LEFT JOIN zing_hours AS h ON l.loc_id=h.loc_id LEFT JOIN zing_cuisines AS c ON l.loc_cuisine=c.cuisine_id WHERE l.loc_id='$this->loc_id'"; } if($this->Reporttype=="Fetch_Four_latest_Records") { $Query = "SELECT a. * , b. * FROM `zing_banners` AS a, zing_eatery_locations AS b WHERE a.`banner_loc_id` = b.loc_id ORDER BY b.loc_id DESC LIMIT 0 , 5"; //$Query = "select * from `zing_eatery_locations` order by loc_id limit 0,4"; } if($this->Reporttype=="Fetch_Active_Market") { $Query = "SELECT DISTINCT `loc_city` , `loc_state` FROM `zing_eatery_locations`"; //$Query = "select * from `zing_eatery_locations` order by loc_id limit 0,4"; } if($this->Reporttype=="Fetch_Most_recent_In_Active_Market") { // $Query = "SELECT * FROM `zing_eatery_locations` WHERE `loc_city`='$this->loc_city' AND `loc_state`='$this->loc_state' ORDER BY loc_id DESC LIMIT 0,5"; $Query = "SELECT a. * , b. * FROM `zing_banners` AS a, zing_eatery_locations AS b WHERE a.`banner_loc_id` = b.loc_id AND `loc_city`='$this->loc_city' AND `loc_state`='$this->loc_state' ORDER BY b.loc_id DESC LIMIT 0 , 5"; //$Query = "select * from `zing_eatery_locations` order by loc_id limit 0,4"; //echo $Query; } if($this->Reporttype=="Fetch_Distinct_City") { $Query = "SELECT DISTINCT `loc_city` FROM `zing_eatery_locations` WHERE loc_city <> '' "; //$Query = "select * from `zing_eatery_locations` order by loc_id limit 0,4"; } if($this->Reporttype=="Fetch_Search_Result_City_Cuisine") { $Query = "SELECT * FROM `zing_eatery_locations` as A LEFT JOIN `zing_cuisines` as B ON A.loc_cuisine = B.cuisine_id ".$this->condition ; } return $this->SelectQuery($Query); } }//class ?>