Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions class.MySQL.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function __construct($database, $username, $password, $hostname='localhost', $po
// Connects class to database
// $persistant (boolean) - Use persistant connection?
private function Connect($persistant = false){
$this->CloseConnection();
$this->closeConnection();

if($persistant){
$this->databaseLink = mysql_pconnect($this->hostname, $this->username, $this->password);
Expand Down Expand Up @@ -115,14 +115,14 @@ private function SecureData($data){
* ******************/

// Executes MySQL query
function ExecuteSQL($query){
function executeSQL($query){
$this->lastQuery = $query;
if($this->result = mysql_query($query, $this->databaseLink)){
$this->records = @mysql_num_rows($this->result);
$this->affected = @mysql_affected_rows($this->databaseLink);

if($this->records > 0){
$this->ArrayResults();
$this->arrayResults();
return $this->arrayedResult;
}else{
return true;
Expand All @@ -136,7 +136,7 @@ function ExecuteSQL($query){


// Adds a record to the database based on the array key names
function Insert($vars, $table, $exclude = ''){
function insert($table, $vars, $exclude = ''){

// Catch Exclusions
if($exclude == ''){
Expand All @@ -159,11 +159,11 @@ function Insert($vars, $table, $exclude = ''){

$query = substr($query, 0, -2);

return $this->ExecuteSQL($query);
return $this->executeSQL($query);
}

// Deletes a record from the database
function Delete($table, $where='', $limit='', $like=false){
function delete($table, $where='', $limit='', $like=false){
$query = "DELETE FROM `{$table}` WHERE ";
if(is_array($where) && $where != ''){
// Prepare Variables
Expand All @@ -178,20 +178,20 @@ function Delete($table, $where='', $limit='', $like=false){
$query .= "`{$key}` = '{$value}' AND ";
}
}

$query = substr($query, 0, -5);
}

if($limit != ''){
$query .= ' LIMIT ' . $limit;
}

return $this->ExecuteSQL($query);
return $this->executeSQL($query);
}


// Gets a single row from $from where $where is true
function Select($from, $where='', $orderBy='', $limit='', $like=false, $operand='AND',$cols='*'){
function select($from, $where='', $orderBy='', $limit='', $like=false, $operand='AND',$cols='*'){
// Catch Exceptions
if(trim($from) == ''){
return false;
Expand Down Expand Up @@ -227,12 +227,12 @@ function Select($from, $where='', $orderBy='', $limit='', $like=false, $operand=
$query .= ' LIMIT ' . $limit;
}

return $this->ExecuteSQL($query);
return $this->executeSQL($query);

}

// Updates a record in the database based on WHERE
function Update($table, $set, $where, $exclude = ''){
function update($table, $set, $where, $exclude = ''){
// Catch Exceptions
if(trim($table) == '' || !is_array($set) || !is_array($where)){
return false;
Expand Down Expand Up @@ -269,7 +269,7 @@ function Update($table, $set, $where, $exclude = ''){

$query = substr($query, 0, -5);

return $this->ExecuteSQL($query);
return $this->executeSQL($query);
}

// 'Arrays' a single result
Expand All @@ -279,7 +279,7 @@ function ArrayResult(){
}

// 'Arrays' multiple result
function ArrayResults(){
function arrayResults(){

if($this->records == 1){
return $this->ArrayResult();
Expand All @@ -293,7 +293,7 @@ function ArrayResults(){
}

// 'Arrays' multiple results with a key
function ArrayResultsWithKey($key='id'){
function arrayResultsWithKey($key='id'){
if(isset($this->arrayedResult)){
unset($this->arrayedResult);
}
Expand All @@ -307,18 +307,18 @@ function ArrayResultsWithKey($key='id'){
}

// Returns last insert ID
function LastInsertID(){
function lastInsertID(){
return mysql_insert_id();
}

// Return number of rows
function CountRows($from, $where=''){
$result = $this->Select($from, $where, '', '', false, 'AND','count(*)');
function countRows($from, $where=''){
$result = $this->select($from, $where, '', '', false, 'AND','count(*)');
return $result["count(*)"];
}

// Closes the connections
function CloseConnection(){
function closeConnection(){
if($this->databaseLink){
mysql_close($this->databaseLink);
}
Expand Down