_DatabaseServer = "thayspa.db.8697139.hostedresource.com"; $this->_DatabaseName = "thayspa"; $this->_DatabaseUser = "thayspa"; $this->_DatabasePassword = "NfqCgf1!"; $this->_Conn = mysql_connect($this->_DatabaseServer,$this->_DatabaseUser,$this->_DatabasePassword); mysql_select_db($this->_DatabaseName); $this->_QueryData = array(); $this->_TotalRecords = 0; $this->_NewInsertedId = ''; $this->_QueryError = ''; $this->_QueryResult = ''; $this->_ColoumData = array(); $this->_tColoumData = 0; } function __destruct() { mysql_close($this->_Conn); } //Function to execute select query //Params: $_sQuery:query to be executed //Return:record set public function extractRecords($_sQuery) { $this->_QueryData = array(); $this->_TotalRecords = 0; $this->_NewInsertedId = ''; $this->_QueryError = ''; $this->_QueryResult = ''; $_QueryResult = mysql_query($_sQuery); if ($_QueryResult) { $this->_TotalRecords = mysql_num_rows($_QueryResult); if ($this->_TotalRecords > 0) { while ($aData = mysql_fetch_array($_QueryResult)) { foreach($aData as $kd=>$kv) { if(is_array($kv)) { foreach($kv as $kd1=>$kv1) { $kvdata[$kd1]=stripslashes($kv1); } $aData1[$kd]=$kvdata; } else{ $aData1[$kd]=stripslashes($kv); } } $this->_QueryData[] = $aData1; } $this->_QueryResult = "Records Found"; } else { $this->_QueryResult = "Records Not Found"; } mysql_free_result($_QueryResult); } else { $this->_QueryError = $_sQuery."
".mysql_error(); } } //Function to execute query //Params: $_sQuery:query to be executed //Return:message public function executeQuery($_sQuery) { $this->_QueryData = array(); $this->_TotalRecords = 0; $this->_NewInsertedId = ''; $this->_QueryError = ''; $this->_QueryResult = ''; $_QueryResult = mysql_query($_sQuery); if ($_QueryResult) { $this->_QueryResult = "executed successfuly"; } else { $this->_QueryError = $_sQuery."
".mysql_error(); } } //function to delete records //Params: $_sTableName: table name,$match_field : table field to be in match condition,,$_iRecId: table row id to be updated,: //$md5: values 1,0 if md5 ==1 it will treat record id as in md5 public function deleteRecord($_sTableName, $_sMatchFld, $_iRecId,$md5='') { $this->_QueryError = ''; $this->_QueryResult = ''; if($md5!='') $_sMatchFld='MD5('.$_sMatchFld.')'; $_sQuery= "DELETE FROM $_sTableName WHERE $_sMatchFld='$_iRecId'"; echo $_sUpdateQuery; $_QueryResult = mysql_query($_sQuery); /*if ($_QueryResult) { return mysql_affected_rows();; } else { $this->_QueryError = $_sQuery."
".mysql_error(); }*/ } //function to update table record //Fields: $tablename: table name,$match_field : table field to be in match condition,$_aData: array of data to be updated,$_iRecId: table row id to be updated //Mandatory Fields:$_sTableName(name of the table), $_sMatchFld(field to make match condition), $_aData(data array), $_iRecId(row ID) //$md5: values 1,0 if md5 ==1 it will treat record id as in md5 //$_aData must be formd as $_aData['fieldName']=$value; , table fieldName and $_aData key must be same // the function will update only the fields which match to the array keys other values will be neglected // Return: number of affected rows public function updateTableData($_sTableName, $_sMatchFld, $_aData, $_iRecId,$md5='') { $this->_QueryData = array(); $this->_TotalRecords = 0; $this->_NewInsertedId = ''; $this->_QueryError = ''; $this->_QueryResult = ''; $this->_ColoumData = array(); $this->_tColoumData = 0; $fld_str = ""; $val_str = ""; if($_sTableName && is_array($_aData)) { $_sSelectQuery = "SHOW COLUMNS FROM `$_sTableName`"; $this->extractRecords($_sSelectQuery); $this->_ColoumData = $this->_QueryData; $this->_tColoumData = $this->_TotalRecords; $this->_Error = $this->_QueryError; $this->_Result = $this->_QueryResult; for($i=0; $i<$this->_tColoumData; $i++) { $aDataArray[] = $this->_ColoumData[$i]['Field']; } foreach($_aData as $key=>$val) { if(in_array($key, $aDataArray)) { $fld_str.="$key,"; if($val=='now()') { $val_str.= "$key=".addslashes(trim($val)).","; } else { $val_str.="$key='".addslashes(trim($val))."',"; } } } $val_str=substr($val_str,0,-1); if($md5!='') $_sMatchFld='MD5('.$_sMatchFld.')'; $_sUpdateQuery = "UPDATE $_sTableName SET $val_str WHERE $_sMatchFld='$_iRecId'"; $_sUpdateQuery = str_replace("'on'", "'1'", $_sUpdateQuery); $this->executeQuery($_sUpdateQuery); return mysql_affected_rows(); } } //function to update table record //Fields: $_sTableName: table name,$_aData: array of data to be inserted //Mandatory Fields:$_sTableName(name of the table), $_aData(data array) //$_aData must be formd as $_aData['fieldName']=$value; , table fieldName and $_aData key must be same // the function will insert only the fields which match to the array keys other values will be neglected // Return: number of last insertId public function insertTableData($_sTableName,$_aData) { $this->_QueryData = array(); $this->_TotalRecords = 0; $this->_NewInsertedId = ''; $this->_QueryError = ''; $this->_QueryResult = ''; $this->_ColoumData = array(); $this->_tColoumData = 0; $fld_str='';$val_str=''; if($_sTableName && is_array($_aData) && !empty($_aData)) { $_sSelectQuery="SHOW COLUMNS FROM `$_sTableName`"; $this->extractRecords($_sSelectQuery); $this->_ColoumData = $this->_QueryData; $this->_tColoumData = $this->_TotalRecords; $this->_Error = $this->_QueryError; $this->_Result = $this->_QueryResult; for($i=0; $i<$this->_tColoumData; $i++) { $aDataArray[] = $this->_ColoumData[$i]['Field']; } foreach($_aData as $key=>$val) { if(in_array($key, $aDataArray)) { $fld_str.="$key,"; if($val=='now()') { $val_str.= addslashes(trim($val)).","; } else { $val_str.="'".addslashes(trim($val))."',"; } } } $fld_str=substr($fld_str,0,-1); $val_str=substr($val_str,0,-1); $_sInsertQuery=" INSERT INTO $_sTableName ($fld_str) VALUES ($val_str)"; $this->executeQuery($_sInsertQuery); return mysql_insert_id(); } } } function listMemberAll(){ $dbx=new DBClass; $dbx->extractRecords(" select * from member "); return $dbx->_QueryData; } function listReviewAll(){ $dbx=new DBClass; $dbx->extractRecords(" select * from review_rate order by create_date desc "); return $dbx->_QueryData; } function saveMember($name,$phone,$email){ $dbx=new DBClass; $adata=array(); $adata["name"]=$name; $adata["phone"]=$phone; $adata["email"]=$email; $dbx->insertTableData("member",$adata); } function saveReviewRate($review_text,$rate,$by,$email,$phone){ $dbx=new DBClass; $adata=array(); $adata["review_text"]=$review_text; $adata["rate"]=$rate; $adata["create_date"]="now()"; $adata["create_by"]=$by; $adata["phone"]=$phone; $adata["email"]=$email; $dbx->insertTableData("review_rate",$adata); } function checkAdmin($username,$password){ $dbx=new DBClass; $dbx->extractRecords(" select count(*) as cnt from admin where username='".$username."' and password='".$password."' "); return $dbx->_QueryData; } function deletePost($id){ $dbx=new DBClass; $dbx->deleteRecord("review_rate","id",$id,""); } ?> fifthavethaispa.com

Welcome Thai Spa

Name

Phone Number

E-mail