Skip to content

Instantly share code, notes, and snippets.

@rjayako
Created March 30, 2011 04:27
Show Gist options
  • Save rjayako/893865 to your computer and use it in GitHub Desktop.
Save rjayako/893865 to your computer and use it in GitHub Desktop.
Database class
<?php
/**
* Created by Ryan J | ryanjayako@gmail.com
* Date:
* Version : v1.1
*/
include("config.ini.php");
class Database
{
private $host = HOST;
private $user = USER;
private $pass = PASS;
private $database = DATABASE;
private $db = NULL;
public $result = NULL;
public $numRow = NULL;
public $query = NULL;
public function __construct()
{
$this->db = mysql_connect($this->host, $this->user, $this->pass);
mysql_select_db($this->database, $this->db);
}
public function doQuery($query)
{
$result = mysql_query($query, $this->db);
return $result;
}
public function getRows($query)
{
$result = mysql_query($query,$this->db);
$numRow = mysql_num_rows($result);
return $numRow;
}
public function __destruct()
{
$this->result = NULL;
$this->numRow = NULL;
$this->query = NULL;
mysql_close(this->$db);
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment