Created
April 30, 2018 13:33
-
-
Save teramuza/69f28c1c88ab34ada09b78c7f0eb71a1 to your computer and use it in GitHub Desktop.
OOP PHP
This file contains 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 | |
{ | |
var $dbhost = 'localhost'; | |
var $dbuser = 'raja'; | |
var $dbpass = 'min1011'; | |
var $dbname = 'db_oop1'; | |
function __construct() | |
{ | |
$connect = new mysqli($this->dbhost, $this->dbuser, $this->pass,$this->dbname); | |
if($connect->connect_error){ die('DATABASE ERROR : '.$connect->connect_error);} | |
} | |
function getData($table, $select = '*', $where = '') | |
{ | |
if(!$where = ''){ $getWhere = 'where '.$where;}else{ $getWhere = '';} | |
$get = mysqli_query('select '.$select.' from '.$table. ' '.$getWhere); | |
while($d = mysqli_fetch_array($get)){ | |
$data[] = $d; | |
} | |
return $data; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment