Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Database {
- private $host='localhost';
- private $user="admin";
- private $pass="12345";
- private $db="db2";
- function connectToDb() {
- if($conn = mysqli_connect($this->host, $this->user,$this->pass)) {
- if($db=mysqli_select_db($conn,$this->db)) {
- }
- }
- }
- function closeConnection() {
- mysqli_close();
- }
- }
- ?>
- <?php
- class Select extends Database{
- private $tabname;
- function __construct($tablename) {
- $this->connectToDb();
- $this->tabname = $tablename;
- }
- function getRecordById($id) {
- $query = "SELECT * FROM $this->tabname WHERE id = '$id'";
- if($sql=mysqli_query($query)){
- $data=mysqli_fetch_array();
- }
- return $data;
- }
- function getAllData() {
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement