|
Server : Apache/2.2.2 (Fedora) System : Linux App1.pathumtani.go.th 2.6.20-1.2320.fc5smp #1 SMP Tue Jun 12 19:40:16 EDT 2007 i686 User : apache ( 48) PHP Version : 5.2.9 Disable Function : NONE Directory : /var/www/html/pathumthani_eoffice/application/CA/common/ |
Upload File : |
<?php
class database
{
var $connection;
var $host;
var $user;
var $pass;
var $dbName;
function database()
{
global $dbConfig;
$this->host = $dbConfig['Host'];
$this->user = $dbConfig['User'];
$this->pass = $dbConfig['Password'];
$this->dbName = $dbConfig['Database'];
}
function connect()
{
$this->connection = mysql_connect($this->host, $this->user, $this->pass) or die(mysql_error());
//echo $this->dbName;
if($this->connection)
{
mysql_select_db($this->dbName, $this->connection) or die(mysql_error());
$this->query("SET NAMES 'tis620'");
}
}
function query($queryString)
{
//echo $queryString."<br>";
return mysql_query($queryString, $this->connection);
}
function fetch($result)
{
return mysql_fetch_array($result);
}
function numrows($result)
{
return mysql_num_rows($result);
}
function debug($result)
{
print_r(mysql_fetch_array($result));
}
function insertid(){
return mysql_insert_id();
}
function getRecord($table,$field,$where,$value){
$result = mysql_query("SELECT ".$field." FROM ".$table." WHERE ".$where." = '".$value."'");
$record = mysql_fetch_assoc($result);
return $record[$field];
}
function close()
{
mysql_close($this->connection);
}
}
?>