This is connection:
Extends The Connection:
Some Function:
}
<?php
class db_connect {
protected function database_connection(){
$host_name='localhost';
$user_name='root';
$pass='';
$db_name='test';
$link=mysqli_connect($host_name, $user_name, $pass, $db_name);
if(!$link){
die('Connection Error '.mysqli_errno($link));
}
return $link;
}
}
Extends The Connection:
<?php
require 'db_connect.php';
$link='';
class category extends db_connect{
public function __construct() {
$this->link=$this->database_connection();
;
}
Some Function:
public function save_category($data){
$sql="INSERT INTO tbl_category(category_name,category_description,publication_status) VALUES('$data[category_name]','$data[category_description]','$data[publication_status]')";
if(mysqli_query($this->link, $sql)){
$message="Data saved successfully";
return $message;
} else {
die('Query Error '.mysqli_error($this->link));
}
}
public function select_all(){
$sql="SELECT * FROM tbl_category WHERE deletion_status=1";
if(mysqli_query($this->link, $sql)){
$query_result=mysqli_query($this->link, $sql);
return $query_result;
} else {
die('Query Error '.mysqli_error($this->link));
}
}
public function load_data($id){
$sql="SELECT * from tbl_category where category_id='$id' ";
if(mysqli_query($this->link, $sql)){
$all=mysqli_query($this->link, $sql);
return $all;
}else{
die('Query Problem '.mysqli_errno($this->link));
}
}
public function edit_data(){
$sql="UPDATE tbl_category SET category_name='$_POST[category_name]',category_description='$_POST[category_description]',publication_status='$_POST[publication_status]' WHERE category_id='$_POST[category_id]' ";
if(mysqli_query($this->link, $sql)){
$all=mysqli_query($this->link, $sql);
header('Location:edit_category.php');
//return $all;
}else{
die('Query Problem '.mysqli_errno($this->link));
}
}
public function delete_data($category_id){
$sql="UPDATE tbl_category SET deletion_status=0 WHERE category_id='$category_id' ";
if(mysqli_query($this->link, $sql)){
$all=mysqli_query($this->link, $sql);
return $all;
}else{
die('Query Problem '.mysqli_errno($this->link));
}
}
}
কোন মন্তব্য নেই:
একটি মন্তব্য পোস্ট করুন