$tableName = $bill->isIncome ? 'income' : 'bill'; $stmt = $db->prepare("DELETE FROM {$tableName} WHERE id = ? LIMIT 1;"); $stmt->bind_param('i', $id); $stmt->execute(); echo $stmt->affected_rows; } try { switch ($_SERVER['REQUEST_METHOD']) { case 'GET': if (isset($_GET['months']) || isset($_GET['month'])) { selectMonths($db); } else { if (isset($_GET['types']) || isset($_GET['type'])) { selectTypes($db); } else { selectBills($db); } } break; case 'POST': $bill = json_decode(file_get_contents("php://input")); insert($db, $bill); break; case 'PUT': $bill = json_decode(file_get_contents("php://input")); update($db, $bill); break; case 'DELETE': $bill = json_decode(file_get_contents("php://input")); delete($db, $bill->id); break;
$stmt->execute(); echo $stmt->affected_rows; } try { switch ($_SERVER['REQUEST_METHOD']) { case 'GET': if (isset($_GET['weeks']) || isset($_GET['week'])) { selectWeeks($db); } else { if (isset($_GET['months']) || isset($_GET['month'])) { selectMonths($db); } else { if (isset($_GET['days'])) { selectBills($db, $_GET['days']); } else { selectBills($db, null); } } } break; case 'POST': $bill = json_decode(file_get_contents("php://input")); insert($db, $bill); break; case 'PUT': $bill = json_decode(file_get_contents("php://input")); update($db, $bill); break; case 'DELETE': $bill = json_decode(file_get_contents("php://input")); delete($db, $bill->id);