Skip to content

Instantly share code, notes, and snippets.

@nepsdotin
Last active December 16, 2015 14:04
Show Gist options
  • Save nepsdotin/221d5885e9e821e68b2a to your computer and use it in GitHub Desktop.
Save nepsdotin/221d5885e9e821e68b2a to your computer and use it in GitHub Desktop.
<?php
//database class
class database
{
protected $host;
protected $user;
protected $password;
protected $dbname;
protected $conxn;
public $result;
public function __construct()
{
$this->host="localhost";
$this->user="root";
$this->password="";
$this->dbname="sms";
$this->conxn=mysqli_connect($this->host,$this->user,$this->password,$this->dbname);
if(!$this->conxn)
{
$this->errorMessage(mysqli_error($this->conxn));
}
}
//error message
public function errorMessage($message)
{
return $message;
}
public function successMessage($msg)
{
return $msg;
}
//executing the query..yo function le pass gareko sab query haru run garxa
public function execute($query)
{
$this->result=mysqli_query($this->conxn,$query);
if(!$this->result)
{
$this->errorMessage(mysqli_error($this->conxn));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment