mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-08-17 16:51:00 +00:00
fix: replacement for mysqli_stmt_get_result() for non-mysqlnd servers
Closes #258
This commit is contained in:
+30
-1
@@ -214,7 +214,36 @@ class MYSQLi_DB implements IDbConnection {
|
|||||||
// execute the statement to get its value back
|
// execute the statement to get its value back
|
||||||
if (mysqli_stmt_execute($prep)) {
|
if (mysqli_stmt_execute($prep)) {
|
||||||
$this->selectQueryCount++;
|
$this->selectQueryCount++;
|
||||||
return mysqli_stmt_get_result($prep);
|
|
||||||
|
// read metadata, so we know what fields we were actually selecting
|
||||||
|
// and can prepare our temporary variables to read them into
|
||||||
|
$resultMetaData = mysqli_stmt_result_metadata($prep);
|
||||||
|
|
||||||
|
$stmtRow = array();
|
||||||
|
$rowReferences = array();
|
||||||
|
while ($field = mysqli_fetch_field($resultMetaData)) {
|
||||||
|
$rowReferences[] = &$stmtRow[$field->name];
|
||||||
|
}
|
||||||
|
mysqli_free_result($resultMetaData);
|
||||||
|
|
||||||
|
// now call bind_result with all our variables to recive the data prepared
|
||||||
|
call_user_func_array(array($prep, 'bind_result'), $rowReferences);
|
||||||
|
|
||||||
|
// prepare the array-ed result
|
||||||
|
while(mysqli_stmt_fetch($prep)){
|
||||||
|
$row = array();
|
||||||
|
foreach($stmtRow as $key => $value){
|
||||||
|
$row[$key] = $value;
|
||||||
|
}
|
||||||
|
$queryResult[] = $row;
|
||||||
|
}
|
||||||
|
|
||||||
|
// free the result and the prepared statement itself
|
||||||
|
mysqli_stmt_free_result($prep);
|
||||||
|
mysqli_stmt_close($prep);
|
||||||
|
|
||||||
|
// and return the value
|
||||||
|
return $queryResult;
|
||||||
} else {
|
} else {
|
||||||
throw new Exception('Failed to execute an SQL statement!');
|
throw new Exception('Failed to execute an SQL statement!');
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-6
@@ -77,7 +77,7 @@ class User {
|
|||||||
public static function exists(IDbConnection $db, $value) {
|
public static function exists(IDbConnection $db, $value) {
|
||||||
$sql = '(
|
$sql = '(
|
||||||
SELECT
|
SELECT
|
||||||
Count(*) AS in_users
|
Count(*) AS Total
|
||||||
FROM
|
FROM
|
||||||
'.TB_PREFIX.'users
|
'.TB_PREFIX.'users
|
||||||
WHERE
|
WHERE
|
||||||
@@ -86,7 +86,7 @@ class User {
|
|||||||
UNION ALL
|
UNION ALL
|
||||||
(
|
(
|
||||||
SELECT
|
SELECT
|
||||||
Count(*) AS in_act
|
Count(*) AS Total
|
||||||
FROM
|
FROM
|
||||||
'.TB_PREFIX.'activate
|
'.TB_PREFIX.'activate
|
||||||
WHERE
|
WHERE
|
||||||
@@ -95,9 +95,6 @@ class User {
|
|||||||
|
|
||||||
$res = $db->query_new($sql, $value, $value, $value, $value);
|
$res = $db->query_new($sql, $value, $value, $value, $value);
|
||||||
|
|
||||||
// convert result into an array
|
return ($res[0]['Total'] > 0 || $res[1]['Total']);
|
||||||
$res = mysqli_fetch_array($res, MYSQLI_NUM);
|
|
||||||
|
|
||||||
return ($res[0] > 0 || (count($res) > 1 && $res[1] > 0));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user