fixed error in dbmanager
This commit is contained in:
parent
27744031ce
commit
c7fce2d670
|
@ -14,7 +14,7 @@
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
// GNU General Public License for more details.
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
function dbmanager_query ($sql, &$error) {
|
function dbmanager_query ($sql, &$error, $dbconnection) {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
switch ($config["dbtype"]) {
|
switch ($config["dbtype"]) {
|
||||||
|
@ -25,22 +25,49 @@ function dbmanager_query ($sql, &$error) {
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
$sql = html_entity_decode($sql, ENT_QUOTES);
|
$sql = html_entity_decode($sql, ENT_QUOTES);
|
||||||
|
if ($config["mysqli"]) {
|
||||||
$result = mysql_query ($sql);
|
$result = mysqli_query ($dbconnection, $sql);
|
||||||
if ($result === false) {
|
if ($result === false) {
|
||||||
$backtrace = debug_backtrace ();
|
$backtrace = debug_backtrace ();
|
||||||
$error = mysql_error ();
|
$error = mysqli_error ($dbconnection);
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$result = mysql_query ($sql, $dbconnection);
|
||||||
|
if ($result === false) {
|
||||||
|
$backtrace = debug_backtrace ();
|
||||||
|
$error = mysql_error ();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($result === true) {
|
if ($result === true) {
|
||||||
return mysql_affected_rows ();
|
if($config["mysqli"]){
|
||||||
|
return mysqli_affected_rows ($dbconnection);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return mysql_affected_rows ();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while ($row = mysql_fetch_array ($result, MYSQL_ASSOC)) {
|
if($config["mysqli"]){
|
||||||
array_push ($retval, $row);
|
while ($row = mysqli_fetch_array ($result, MYSQL_ASSOC)) {
|
||||||
|
array_push ($retval, $row);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
while ($row = mysql_fetch_array ($result, MYSQL_ASSOC)) {
|
||||||
|
array_push ($retval, $row);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if($config["mysqli"]){
|
||||||
|
mysqli_free_result ($result);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
mysql_free_result ($result);
|
||||||
}
|
}
|
||||||
mysql_free_result ($result);
|
|
||||||
|
|
||||||
if (! empty ($retval))
|
if (! empty ($retval))
|
||||||
return $retval;
|
return $retval;
|
||||||
|
@ -131,8 +158,10 @@ function dbmgr_extension_main () {
|
||||||
echo "<hr />";
|
echo "<hr />";
|
||||||
echo "<br />";
|
echo "<br />";
|
||||||
|
|
||||||
|
$dbconnection = $config['dbconnection'];
|
||||||
$error = '';
|
$error = '';
|
||||||
$result = dbmanager_query ($sql, $error);
|
|
||||||
|
$result = dbmanager_query ($sql, $error, $dbconnection);
|
||||||
|
|
||||||
if ($result === false) {
|
if ($result === false) {
|
||||||
echo '<strong>An error has occured when querying the database.</strong><br />';
|
echo '<strong>An error has occured when querying the database.</strong><br />';
|
||||||
|
|
Loading…
Reference in New Issue