kohjhjhصثقص5572hjkhk7872ثقصثقgdfgdg
Ele57885fddfg872782782782 hjkhj782dfgfghgقفغفغفقhfg555434536
/
home4
/
kisgavwq
/
gpplenergy.com
/
includes
/
classes
/
Upload FileeE
HOME
<?php class dbquery extends SiteData { function exeCute($qry){ $conn = mysqli_connect(SYSTEM_DBHOST,SYSTEM_DBUSER,SYSTEM_DBPWD,SYSTEM_DBNAME); $sql_query = mysqli_query($conn, $qry); while($data = mysqli_fetch_array($sql_query)){ $res_data[] = $data; } return $res_data; } function fetch_data($tbl_nm,$condition="",$order="",$limit=""){ $select = "SELECT * FROM ".$tbl_nm; if($condition!=""){ $select .= " WHERE ".$condition; } if($order!=""){ $select .= " ORDER BY ".$order; } if($limit!=""){ $select .= " LIMIT ".$limit; } //echo $select; exit; $conn = mysqli_connect(SYSTEM_DBHOST,SYSTEM_DBUSER,SYSTEM_DBPWD,SYSTEM_DBNAME); $res = mysqli_query($conn, $select); while($res_row = mysqli_fetch_array($res)){ $res_data[] = $res_row; } return $res_data; } function insertToDb($tbl,$fields){ $insert = "INSERT INTO ".$tbl." SET ".$fields; $conn = mysqli_connect(SYSTEM_DBHOST,SYSTEM_DBUSER,SYSTEM_DBPWD,SYSTEM_DBNAME); $exe = mysqli_query($conn, $insert); if($exe){ $val = 1; }else{ $val = 0; } return $val; } function updateToDb($tbl,$fields,$condition){ $update = "UPDATE ".$tbl." SET ".$fields." WHERE ".$condition; $conn = mysqli_connect(SYSTEM_DBHOST,SYSTEM_DBUSER,SYSTEM_DBPWD,SYSTEM_DBNAME); $exe = mysqli_query($conn, $update); if($exe){ $val = 1; }else{ $val=0; } return $val; } function selectFromDb($tbl,$fields,$all="*",$condition="",$order="",$limit="") { $select = "SELECT "; if($fields!=""){ $select .= $fields; }else{ $select .= $all; } $select .= " FROM ".$tbl." "; if($condition!=""){ $select .= "WHERE ".$condition; } if($order!=""){ $select .= " ".$order; } if($limit!=""){ $select .= $limit; } //echo $select;exit; $exe = $this->exeCute($select); return $exe; } function delete($tbl_nm,$field,$condition){ if($field!=""){ $select = "DELETE ".$field." FROM ".$tbl_nm." WHERE ".$condition; }else{ $select = "DELETE FROM ".$tbl_nm." WHERE ".$condition; } //echo $select;exit; $conn = mysqli_connect(SYSTEM_DBHOST,SYSTEM_DBUSER,SYSTEM_DBPWD,SYSTEM_DBNAME); $sql = mysqli_query($conn, $select); if($sql){ return true; }else{ return false; } } function countRec($tbl_nm,$condition=""){ $select = "SELECT * FROM ".$tbl_nm; if($condition!=""){ $select .= " WHERE ".$condition; } $conn = mysqli_connect(SYSTEM_DBHOST,SYSTEM_DBUSER,SYSTEM_DBPWD,SYSTEM_DBNAME); $row_query = mysqli_query($conn, $select); $num_row = mysqli_num_rows($row_query); return $num_row; } function fetchSingleLatest($tbl_nm,$condition="",$key=""){ $select = "SELECT * FROM ".$tbl_nm; if($condition!=""){ $select .= " WHERE ".$condition; } if($key!=""){ $select .= " ORDER BY ".$key." LIMIT 1"; } //echo $select;exit; $conn = mysqli_connect(SYSTEM_DBHOST,SYSTEM_DBUSER,SYSTEM_DBPWD,SYSTEM_DBNAME); $qry_exe = mysqli_query($conn, $select); $ret_rec = mysqli_fetch_array($qry_exe); return $ret_rec; } function fetchSingle($tbl_nm,$field,$condition){ if($field!=""){ $select = "SELECT ".$field." FROM "; }else{ $select = "SELECT * FROM "; } $select .= $tbl_nm." WHERE ".$condition; $conn = mysqli_connect(SYSTEM_DBHOST,SYSTEM_DBUSER,SYSTEM_DBPWD,SYSTEM_DBNAME); $sql = mysqli_query($conn, $select); $data_row = mysqli_num_rows($sql); if($data_row>0){ $rec = mysqli_fetch_array($sql); return $rec; }else{ $rec=0; return $rec; } } function checkDuplicate($tbl_nm,$condition){ $select = "SELECT * FROM ".$tbl_nm." WHERE ".$condition; $conn = mysqli_connect(SYSTEM_DBHOST,SYSTEM_DBUSER,SYSTEM_DBPWD,SYSTEM_DBNAME); $sql = mysqli_query($conn, $select); $row = mysqli_num_rows($sql); if($row>0){ return 1; }else{ return 0; } } function enableReview($id) { $id = inText($id); $sql = "UPDATE tbl_user set review_status='1' where id='$id'"; $res = $this->update($sql); $msg = "success"; return $msg; } function disableReview($id) { $id = inText($id); $sql = "UPDATE tbl_user set review_status='0' where id='$id'"; $res = $this->update($sql); $msg = "success"; return $msg; } function fetch_old_data($tbl_nm,$condition="",$order="",$limit=""){ $select = "SELECT * FROM ".$tbl_nm; if($condition!=""){ $select .= " WHERE ".$condition; } if($order!=""){ $select .= " ORDER BY ".$order; } if($limit!=""){ $select .= " LIMIT ".$limit; } //echo $select; exit; $conn = mysqli_connect(SYSTEM_DBHOST,SYSTEM_DBUSER,SYSTEM_DBPWD,SYSTEM_DBNAME); $res = mysqli_query($conn, $select); while($res_row = mysqli_fetch_array($res)){ $res_data[] = $res_row; } return $res_data; } function getUniqID($insert_id){ $get_new_id = "FB".sprintf("%04d",$insert_id); $upd_uniq_id = $this->updateToDb("fran_details","unique_key = '$get_new_id'","id = $insert_id"); } function insertToUser($tbl,$fields){ $insert = "INSERT INTO ".$tbl." SET ".$fields; $conn = mysqli_connect(SYSTEM_DBHOST,SYSTEM_DBUSER,SYSTEM_DBPWD,SYSTEM_DBNAME); $exe = mysqli_query($conn, $insert); if($exe){ $val = mysql_insert_id(); $new_val = "JM1".sprintf("%06d",$val); $new_upd = "UPDATE ".$tbl." SET Unique_id = '$new_val' WHERE id = '$val'"; $test = mysqli_query($conn, $new_upd); $new_upd1 = $this->insertToDb("tbl_personal","Profile_id='$new_val'"); $new_upd1 = $this->insertToDb("tbl_family","Profile_id='$new_val'"); $new_upd1 = $this->insertToDb("tbl_partner","Profile_id='$new_val'"); $new_upd1 = $this->insertToDb("tbl_usr_photos","Profile_id='$new_val'"); $_SESSION['profileid']=$new_val; $val = 1; }else{ $val = 0; } return $val; } function get_user_info($query){ $select = $query; $conn = mysqli_connect(SYSTEM_DBHOST,SYSTEM_DBUSER,SYSTEM_DBPWD,SYSTEM_DBNAME); $res = mysqli_query($conn, $select); while($res_row = mysqli_fetch_array($res)){ $res_data[] = $res_row; } return $res_data; } function get_user_info1($query){ $query; $select = $query; $conn = mysqli_connect(SYSTEM_DBHOST,SYSTEM_DBUSER,SYSTEM_DBPWD,SYSTEM_DBNAME); $res = mysqli_query($conn, $select); while($res_row = mysqli_fetch_array($res)){ $res_data[] = $res_row; } return $res_data; } } ?>