| Server IP : 104.21.80.248 / Your IP : 172.71.28.156 Web Server : Apache/2.4.25 (Win32) OpenSSL/1.0.2j PHP/5.6.30 System : Windows NT WIN-ECQAAA40806 6.2 build 9200 (Windows Server 2012 Standard Edition) i586 User : SYSTEM ( 0) PHP Version : 5.6.30 Disable Function : NONE MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /Inetpub/www/myschool/triamudom/check/include/ |
Upload File : |
<?php
/**
*------------------------
* Require configuration value for connect to data base
* Copyright (c)2003 Jira Hi
*------------------------
*/
class db {
var $conn_id;
var $result;
var $record;
var $db = array();
var $port;
var $query_count=0;
var $sql;
var $SID='';
var $typeConn;
function db() {
global $DB,$SID;
$this->db = $DB;
if(ereg(":",$this->db['host'])) {
list($host,$port) = explode(":",$this->db['host']);
$this->port = $port;
} else {
$this->port = 3306;
}
$this->SID = $SID;
$this->typeConn = 'mysql';
$this->typeConn2 = 'mysql';
}
function connect() {
if ($this->typeConn=='mysql')
$this->conn_id = mysql_connect($this->db['host'].":".$this->port,$this->db['user'],$this->db['pass']);
else if ($this->typeConn=='mssql')
$this->conn_id = mssql_connect($this->db['host'],$this->db['user'],$this->db['pass']);
if ($this->conn_id == 0) {
$this->sql_error("Connection Error");
}
if ($this->typeConn=='mysql') {
if (!mysql_select_db($this->db['dbName'], $this->conn_id)) {
$this->sql_error("Database Error");
}else{
/* mysql_query("SET NAMES TIS-620");
mysql_query("SET character_set_results=tis620");
mysql_query("SET character_set_client='tis620'");
mysql_query("SET character_set_connection='tis620'");
mysql_query("collation_connection = tis620_thai_ci");
mysql_query("collation_database = tis620_thai_ci");
mysql_query("collation_server = tis620_thai_ci");*/
mysql_query("SET NAMES UTF8");
mysql_query("SET character_set_results=utf8");
mysql_query("SET character_set_client=utf8");
mysql_query("SET character_set_connection=utf8");
}
}else if ($this->typeConn=='mssql') {
if (!mssql_select_db($this->db['dbName'], $this->conn_id)) {
$this->sql_error("Database Error");
}
}
return $this->conn_id;
}
function query($query_string) {
if ($this->typeConn=='mysql')
$this->result = mysql_query($query_string,$this->conn_id);
else if ($this->typeConn=='mssql')
$this->result = mssql_query($query_string,$this->conn_id);
$this->sql = $query_string;
$this->query_count++;
return $this->result;
}
function fetch_array($query_id) {
if ($this->typeConn=='mysql')
$this->record = mysql_fetch_array($query_id,MYSQL_ASSOC);
else if ($this->typeConn=='mssql')
$this->record = mssql_fetch_array($query_id);
return $this->record;
}
function num_rows($query_id) {
if ($this->typeConn=='mysql')
return ($query_id) ? mysql_num_rows($query_id) : 0;
else if ($this->typeConn=='mssql')
return ($query_id) ? mssql_num_rows($query_id) : 0;
}
function num_fields($query_id) {
if ($this->typeConn=='mysql')
return ($query_id) ? mysql_num_fields($query_id) : 0;
else if ($this->typeConn=='mssql')
return ($query_id) ? mssql_num_fields($query_id) : 0;
}
function free_result($query_id) {
if ($this->typeConn=='mysql')
return mysql_free_result($query_id);
else if ($this->typeConn=='mssql')
return mssql_free_result($query_id);
}
function close_db() {
if ($this->typeConn=='mysql') {
if($this->conn_id) {
return mysql_close($this->conn_id);
} else {
return false;
}
}else if ($this->typeConn=='mssql') {
if($this->conn_id) {
return mssql_close($this->conn_id);
} else {
return false;
}
}
}
}//end class
?>