upgrade matrice with files
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
include('include/headscript.php');
|
||||
header('Content-Type: application/json');
|
||||
|
||||
$id = isset($_POST['id']) ? (int)$_POST['id'] : 0;
|
||||
if ($id <= 0) {
|
||||
echo json_encode(['success' => false, 'message' => 'Invalid id']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$db = DBHandlerSelect::getInstance();
|
||||
$pdo = $db->getConnection();
|
||||
|
||||
try {
|
||||
// flip 1 <-> 0
|
||||
$stmt = $pdo->prepare("UPDATE mescole SET is_active = IF(is_active=1,0,1) WHERE id = ?");
|
||||
$stmt->execute([$id]);
|
||||
|
||||
// verifica righe aggiornate
|
||||
if ($stmt->rowCount() === 0) {
|
||||
echo json_encode(['success' => false, 'message' => 'No rows updated (id not found?)']);
|
||||
exit;
|
||||
}
|
||||
|
||||
echo json_encode(['success' => true]);
|
||||
} catch (PDOException $e) {
|
||||
echo json_encode(['success' => false, 'message' => $e->getMessage()]);
|
||||
}
|
||||
Reference in New Issue
Block a user