Skip to content

Commit

Permalink
report, ressources: mysql -> mysqli update #54
Browse files Browse the repository at this point in the history
The process was the same as:
ndlibersa/resources@26ae17c
(saved on https://archive.is if repo is deleted)

And fix error in management conversion
  • Loading branch information
tuxayo committed Jul 5, 2016
1 parent 794bb6b commit 893abdb
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion management/admin/classes/common/DBService.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ protected function disconnect() {
}

public function escapeString($value) {
return $this->db->escapeString($value);
return $this->db->real_escape_string($value);
}

public function query($sql) {
Expand Down
50 changes: 25 additions & 25 deletions reports/install/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@
}else{

//first check connecting to host
$link = @mysql_connect("$database_host", "$database_username", "$database_password");
if (!$link) {
$errorMessage[] = "Could not connect to the server '" . $database_host . "'<br />MySQL Error: " . mysql_error();
$link = new mysqli("$database_host", "$database_username", "$database_password");
if ($link->connect_error) {
$errorMessage[] = "Could not connect to the server '" . $database_host . "'<br />MySQL Error: " . $link->error;
}else{

//next check that the database exists
$dbcheck = @mysql_select_db("$database_name");
$dbcheck = $link->select_db("$database_name");
if (!$dbcheck) {
$errorMessage[] = "Unable to access the database '" . $database_name . "'. Please verify it has been created.<br />MySQL Error: " . mysql_error();
$errorMessage[] = "Unable to access the database '" . $database_name . "'. Please verify it has been created.<br />MySQL Error: " . $link->error;
}else{
//passed db host, name check, can open/run file now
//make sure SQL file exists
Expand All @@ -55,12 +55,12 @@

//Process the sql file by statements
foreach ($sqlArray as $stmt) {
if (strlen(trim($stmt))>3) {
if (strlen(trim($stmt))>3) {

$result = mysql_query($stmt);
$result = $link->query($stmt);
if (!$result) {
$errorMessage[] = mysql_error() . "<br /><br />For statement: " . $stmt;
break;
$errorMessage[] = $link->error . "<br /><br />For statement: " . $stmt;
break;
}
}
}
Expand All @@ -78,12 +78,12 @@

//Process the sql file by statements
foreach ($sqlArray as $stmt) {
if (strlen(trim($stmt))>3) {
if (strlen(trim($stmt))>3) {

$result = mysql_query($stmt);
$result = $link->query($stmt);
if (!$result) {
$errorMessage[] = mysql_error() . "<br /><br />For statement: " . $stmt;
break;
$errorMessage[] = $link->error . "<br /><br />For statement: " . $stmt;
break;
}
}
}
Expand All @@ -92,15 +92,15 @@
}

//next check the usage database exists
$dbcheck = @mysql_select_db("$usage_database_name");
$dbcheck = $link->select_db("$database_name");
if (!$dbcheck) {
$errorMessage[] = "Unable to access the usage database '" . $usage_database_name . "'. Please verify it has been created.<br />MySQL Error: " . mysql_error();
$errorMessage[] = "Unable to access the usage database '" . $usage_database_name . "'. Please verify it has been created.<br />MySQL Error: " . $link->error;
}else{

//passed db host, name check, test that user can select from License database
$result = mysql_query("SELECT outlierID FROM " . $usage_database_name . ".Outlier WHERE outlierLevel = '1';");
$result = $link->query("SELECT outlierID FROM " . $usage_database_name . ".Outlier WHERE outlierLevel = '1';");
if (!$result) {
$errorMessage[] = "Unable to select from the Outlier table in database '" . $usage_database_name . "' with user '" . $database_username . "'. Please complete the Usage install and verify the database has been set up. Error: " . mysql_error();
$errorMessage[] = "Unable to select from the Outlier table in database '" . $usage_database_name . "' with user '" . $database_username . "'. Please complete the Usage install and verify the database has been set up. Error: " . $link->error;
}
}

Expand Down Expand Up @@ -132,22 +132,22 @@
}else{

//first check connecting to host
$link = @mysql_connect("$database_host", "$database_username", "$database_password");
if (!$link) {
$errorMessage[] = "Could not connect to the server '" . $database_host . "'<br />MySQL Error: " . mysql_error();
$link = new mysqli("$database_host", "$database_username", "$database_password");
if ($link->connect_error) {
$errorMessage[] = "Could not connect to the server '" . $database_host . "'<br />MySQL Error: " . $link->error;
}else{

//next check that the database exists
$dbcheck = @mysql_select_db("$database_name");
$dbcheck = $link->select_db("$database_name");
if (!$dbcheck) {
$errorMessage[] = "Unable to access the database '" . $database_name . "'. Please verify it has been created.<br />MySQL Error: " . mysql_error();
$errorMessage[] = "Unable to access the database '" . $database_name . "'. Please verify it has been created.<br />MySQL Error: " . $link->error;
}else{
//passed db host, name check, test that user can select from Reports database
$result = mysql_query("SELECT reportID FROM " . $database_name . ".Report WHERE reportName like '%Usage%';");
$result = $link->query("SELECT reportID FROM " . $database_name . ".Report WHERE reportName like '%Usage%';");
if (!$result) {
$errorMessage[] = "Unable to select from the Report table in database '" . $database_name . "' with user '" . $database_username . "'. Error: " . mysql_error();
$errorMessage[] = "Unable to select from the Report table in database '" . $database_name . "' with user '" . $database_username . "'. Error: " . $link->error;
}else{
while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
while ($row = $result->fetch_array(MYSQLI_NUM)) {
$reportID = $row[0];
}

Expand Down
2 changes: 1 addition & 1 deletion reports/install/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
try {
$result = $dbservice->query("SELECT reportID FROM " . Config::$database->name . ".Report WHERE reportName like '%Usage%';");
} catch (RuntimeException $exception) {
$errorMessage[] = "Unable to select from the Report table in database '" . Config::$database->name . "' with user '" . Config::$database->username . "'. Error: " . mysql_error();
$errorMessage[] = "Unable to select from the Report table in database '" . Config::$database->name . "' with user '" . Config::$database->username . "'. Error: " . $dbservice->error();
}

if (count($errorMessage)===0) {
Expand Down
2 changes: 1 addition & 1 deletion resources/admin/classes/domain/Resource.php
Original file line number Diff line number Diff line change
Expand Up @@ -1130,7 +1130,7 @@ public static function getSearchDetails() {
$whereAdd[] = "((RPAY.fundID IS NULL) OR (RPAY.fundID = '0'))";
$searchDisplay[] = "Fund: none";
}else if ($search['fund']) {
$fund = mysql_real_escape_string(str_replace("-","",$search['fund']));
$fund = mysqli_real_escape_string(str_replace("-","",$search['fund']));
$whereAdd[] = "REPLACE(RPAY.fundID,'-','') = '" . $fund . "'";
$searchDisplay[] = "Fund: " . $search['fund'];
}
Expand Down

0 comments on commit 893abdb

Please sign in to comment.