Skip to content

Instantly share code, notes, and snippets.

@rjayako
Created March 21, 2011 04:20
Show Gist options
  • Save rjayako/879007 to your computer and use it in GitHub Desktop.
Save rjayako/879007 to your computer and use it in GitHub Desktop.
Database query object
<?php
/**
* Created by JetBrains PhpStorm.
* User: ryanjayakody
* Date: 11-03-09
* Time: 3:52 PM
* To change this template use File | Settings | File Templates.
*/
include("config.ini");
class Database
{
private $host = HOST;
private $user = USER;
private $pass = PASS;
private $database = DATABASE;
private $db = NULL;
public $result = NULL;
public $numRow = NULL;
public $assocResult = 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 numRows($result)
{
$numRow = mysql_num_rows($result);
return $numRow;
}
public function __destruct()
{
$this->result = NULL;
$this->numRow = NULL;
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment