Created
January 6, 2018 10:37
-
-
Save codersaiful/fd6c19b9a57128936cd44b68ffeeba3d to your computer and use it in GitHub Desktop.
Bangla Font issue Solution
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
Class Database { | |
public $host = DB_HOST; | |
public $user = DB_USER; | |
public $pass = DB_PASS; | |
public $dbname = DB_NAME; | |
public $link; | |
public $error; | |
public function __construct() { | |
$this->connectDB(); | |
/* You also can use here. Adding additional for fixing bangla Font Issue | |
$this->link->query("SET NAMES utf8"); | |
$this->link->query("SET CHARACTER SET utf8"); | |
$this->link->set_charset('utf8'); | |
$this->link->set_charset('utf-8'); | |
//End of Addintional issue by Saiful Islam */ | |
} | |
/** | |
* Connecting Database with mysql | |
* | |
* @author Saiful Islam<[email protected]> | |
* @return Object | |
*/ | |
private function connectDB() { | |
$this->link = new mysqli($this->host, $this->user, $this->pass, $this->dbname); | |
//Adding additional for fixing bangla Font Issue | |
$this->link->query("SET NAMES utf8"); | |
$this->link->query("SET CHARACTER SET utf8"); | |
$this->link->set_charset('utf8'); | |
$this->link->set_charset('utf-8'); | |
//End of Addintional issue by Saiful Islam | |
if (!$this->link) { | |
$this->error = "Connection fail" . $this->link->connect_error; | |
return false; | |
} | |
} | |
// Select or Read data | |
public function select($query) { | |
$result = $this->link->query($query) or die($this->link->error . __LINE__); | |
if ($result->num_rows > 0) { | |
return $result; | |
} else { | |
return false; | |
} | |
} | |
// Insert data | |
public function insert($query) { | |
$insert_row = $this->link->query($query) or die($this->link->error . __LINE__); | |
if ($insert_row) { | |
header("Location: index.php?msg=" . urlencode('Data Inserted successfully.')); | |
exit(); | |
} else { | |
die("Error :(" . $this->link->errno . ")" . $this->link->error); | |
} | |
} | |
// Update data | |
public function update($query) { | |
$update_row = $this->link->query($query) or die($this->link->error . __LINE__); | |
if ($update_row) { | |
header("Location: index.php?msg=" . urlencode('Data Updated successfully.')); | |
exit(); | |
} else { | |
die("Error :(" . $this->link->errno . ")" . $this->link->error); | |
} | |
} | |
// Delete data | |
public function delete($query) { | |
$delete_row = $this->link->query($query) or die($this->link->error . __LINE__); | |
if ($delete_row) { | |
header("Location: index.php?msg=" . urlencode('Data Deleted successfully.')); | |
exit(); | |
} else { | |
die("Error :(" . $this->link->errno . ")" . $this->link->error); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment