Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class DBController {
- private $host = "localhost";
- private $user = "Admin";
- private $password = "1234";
- private $database = "dbtest";
- function __construct() {
- $conn = $this->connectDB();
- if(!empty($conn)) {
- $this->selectDB($conn);
- }
- }
- function connectDB() {
- $conn = mysqli_connect($this->host,$this->user,$this->password);
- return $conn;
- }
- function selectDB($conn) {
- mysqli_select_db($conn, $this->database);
- }
- function runQuery($query) {
- $result = mysqli_query($query);
- while($row=mysqli_fetch_assoc($result)) {
- $resultset[] = $row;
- }
- if(!empty($resultset))
- return $resultset;
- }
- function numRows($query) {
- $result = mysqli_query($query);
- $rowcount = mysqli_num_rows($result);
- return $rowcount;
- }
- mysqli_query($conn,$query);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement