Created
December 24, 2013 16:23
-
-
Save rschiang/8115286 to your computer and use it in GitHub Desktop.
rsPlurkAI training site PHP connection code in 2011
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once("functions.php"); | |
class AIDatabase { | |
var $m_conn = 0; | |
var $m_query = 0; | |
// Constructor | |
function AIDatabase() {} | |
// Functions | |
function Connect() { | |
require("config.php"); | |
$conn = mysql_connect($sch["host"], $sch["user"], $sch["psw"]); | |
if (!$conn) terminal(101); | |
mysql_query("SET NAMES 'utf8'"); | |
if (!mysql_select_db($sch["db"], $conn)) terminal(102); | |
$this->m_conn = $conn; | |
return true; | |
} | |
function Query($sqlStatement) { | |
$query = mysql_query($sqlStatement, $this->m_conn); | |
if (!$query) terminal(103); | |
$this->m_query = $query; | |
return $query; | |
} | |
function RowCount() { | |
return mysql_num_rows($this->m_query); | |
} | |
function Rows() { | |
return mysql_fetch_array($this->m_query, MYSQL_ASSOC); | |
} | |
function InsertId() { | |
return mysql_insert_id($this->m_conn); | |
} | |
function AffectedRowCount() { | |
return mysql_affected_rows($this->m_conn); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment