Skip to content

Commit e1b219e

Browse files
author
Alex Warhawk
committed
added possibility to create more than one instances, the mysql function calls now use the sDBLink handle
also corrected a syntax error
1 parent 02f9659 commit e1b219e

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

class.MySQL.php

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@
2020
// MySQL Class
2121
class MySQL {
2222
// Base variables
23-
var $sLastError; // Holds the last error
24-
var $sLastQuery; // Holds the last query
25-
var $aResult; // Holds the MySQL query result
26-
var $iRecords; // Holds the total number of records returned
27-
var $iAffected; // Holds the total number of records affected
28-
var $aRawResults; // Holds raw 'arrayed' results
29-
var $aArrayedResult; // Holds a single 'arrayed' result
30-
var $aArrayedResults; // Holds multiple 'arrayed' results (usually with a set key)
23+
var $sLastError; // Holds the last error
24+
var $sLastQuery; // Holds the last query
25+
var $aResult; // Holds the MySQL query result
26+
var $iRecords; // Holds the total number of records returned
27+
var $iAffected; // Holds the total number of records affected
28+
var $aRawResults; // Holds raw 'arrayed' results
29+
var $aArrayedResult; // Holds a single 'arrayed' result
30+
var $aArrayedResults; // Holds multiple 'arrayed' results (usually with a set key)
3131

3232
var $sHostname = MYSQL_HOST; // MySQL Hostname
3333
var $sUsername = MYSQL_USER; // MySQL Username
@@ -56,21 +56,21 @@ function Connect($bPersistant = false){
5656
}
5757

5858
if (!$this->sDBLink){
59-
$this->sLastError = 'Could not connect to server: ' . mysql_error();
59+
$this->sLastError = 'Could not connect to server: ' . mysql_error($this->sDBLink);
6060
return false;
6161
}
6262

6363
if(!$this->UseDB()){
64-
$this->sLastError = 'Could not connect to database: ' . mysql_error();
64+
$this->sLastError = 'Could not connect to database: ' . mysql_error($this->sDBLink);
6565
return false;
6666
}
6767
return true;
6868
}
6969

7070
// Select database to use
7171
function UseDB(){
72-
if (!mysql_select_db($this->sDatabase)) {
73-
$this->sLastError ='Cannot select database: ' . mysql_error();
72+
if (!mysql_select_db($this->sDatabase, $this->sDBLink)) {
73+
$this->sLastError ='Cannot select database: ' . mysql_error($this->sDBLink);
7474
return false;
7575
}else{
7676
return true;
@@ -80,12 +80,12 @@ function UseDB(){
8080
// Executes MySQL query
8181
function ExecuteSQL($sSQLQuery){
8282
$this->sLastQuery = $sSQLQuery;
83-
if($this->aResult = mysql_query($sSQLQuery)){
83+
if($this->aResult = mysql_query($sSQLQuery, $this->sDBLink)){
8484
$this->iRecords = @mysql_num_rows($this->aResult);
85-
$this->iAffected = @mysql_affected_rows();
85+
$this->iAffected = @mysql_affected_rows($this->sDBLink);
8686
return true;
8787
}else{
88-
$this->sLastError = mysql_error();
88+
$this->sLastError = mysql_error($this->sDBLink);
8989
return false;
9090
}
9191
}
@@ -244,14 +244,14 @@ function Update($sTable, $aSet, $aWhere, $aExclude = ''){
244244

245245
// 'Arrays' a single result
246246
function ArrayResult(){
247-
$this->aArrayedResult = mysql_fetch_assoc($this->aResult) or die (mysql_error());
247+
$this->aArrayedResult = mysql_fetch_assoc($this->aResult) or die (mysql_error($this->sDBLink));
248248
return $this->aArrayedResult;
249249
}
250250

251251
// 'Arrays' multiple result
252252
function ArrayResults(){
253253
$this->aArrayedResults = array();
254-
while ($aData = mysql_fetch_assoc($this->aResult){
254+
while ($aData = mysql_fetch_assoc($this->aResult)){
255255
$this->aArrayedResults[] = $aData;
256256
}
257257
return $this->aArrayedResults;
@@ -276,14 +276,14 @@ function SecureData($aData){
276276
if(is_array($aData)){
277277
foreach($aData as $iKey=>$sVal){
278278
if(!is_array($aData[$iKey])){
279-
$aData[$iKey] = mysql_real_escape_string($aData[$iKey]);
279+
$aData[$iKey] = mysql_real_escape_string($aData[$iKey], $this->sDBLink);
280280
}
281281
}
282282
}else{
283-
$aData = mysql_real_escape_string($aData);
283+
$aData = mysql_real_escape_string($aData, $this->sDBLink);
284284
}
285285
return $aData;
286286
}
287287
}
288-
?>
289288

289+
?>

0 commit comments

Comments
 (0)