Skip to content

Commit

Permalink
Update index.php
Browse files Browse the repository at this point in the history
  • Loading branch information
gnh1201 committed Jun 21, 2024
1 parent bcaa4e7 commit 1e3059c
Showing 1 changed file with 40 additions and 28 deletions.
68 changes: 40 additions & 28 deletions assets/php/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,42 +239,54 @@ function relay_mysql_query($params, $mysqli) {
if ($pos !== false) {
$query_type = strtolower(substr($query, 0, $pos));
}
$query_result = $mysqli->query($query);

try {
$query_result = $mysqli->query($query);

if ($mysqli->error) {
return array(
"success" => false,
"error" => array(
"status" => 503,
"code" => $msqli->errno,
"message" => $mysqli->error
)
);
}

$success = false;
$result = array(
"status" => 200
);
switch($query_type) {
case "select":
$success = true;
$result['data'] = mysqli_fetch_all($query_result, MYSQLI_ASSOC);
break;

case "insert":
$success = $query_result;
$result['last_id'] = @$mysqli->insert_id();
break;

default:
$success = $query_result;
}

if ($mysqli->error) {
return array(
"success" => $success,
"result" => $result
);
} catch (Exception $e) {
return array(
"success" => false,
"error" => array(
"status" => 503,
"code" => $msqli->errno,
"message" => $mysqli->error
"code" => -1,
"message" => $e->__toString()
)
);
}

$success = false;
$result = array(
"status" => 200
);
switch($query_type) {
case "select":
$success = true;
$result['data'] = mysqli_fetch_all($query_result, MYSQLI_ASSOC);
break;

case "insert":
$success = $query_result;
$result['last_id'] = @$mysqli->insert_id();
break;

default:
$success = $query_result;
}

return array(
"success" => $success,
"result" => $result
);
}

function relay_sendmail($params) {
Expand Down

0 comments on commit 1e3059c

Please sign in to comment.