Hallo,
ich bin auf der Suche nach jemanden der mir meinen MySQLi Teil in einen PDO Teil umschreibt.
Hoffe es findet sich jemand. Aktueller Code
Code
if ($_GET["action"] == "get") {
$tasks = [];
$sql = "SELECT `task_id`, `username`, `subject`, `task`, `timestamp` FROM `tasks` WHERE `done` = '0'";
if ($taskDS = mysqli_query($mysqli_le, $sql)) {
while (list($taskID, $username, $subject, $taskText, $timestamp) = mysqli_fetch_row($taskDS)) {
$task = [];
$task["id"] = $taskID;
$task["creator"] = $username;
$task["subject"] = $subject;
$task["task"] = $taskText;
$task["time"] = date("d.m.Y H:i", $timestamp);
array_push($tasks, $task);
}
}
echo json_encode($tasks);
exit;
}
else if ($_GET["action"] == "add")
{
if (isset($_GET["subject"]) && $_GET["subject"] != ""
&& isset($_GET["task"]) && $_GET["task"] != "")
$sql = "INSERT INTO `tasks` SET `department` = '1', `user_id` = '" . mysqli_real_escape_string($mysqli_le, $user_id) . "',
`username` = '" . mysqli_real_escape_string($mysqli_le, $username) . "',
`subject` = '" . mysqli_real_escape_string($mysqli_le, $_GET["subject"]) . "',
`task` = '" . mysqli_real_escape_string($mysqli_le, $_GET["task"]) . "',
`timestamp` = '" . time() . "'";
if (mysqli_query($mysqli_le, $sql)) {
echo "SUCCESS";
exit;
}
else {
echo 'Ä';
echo "ERROR_MYSQL_QUERY" . $sql;
exit;
}
}
Alles anzeigen