06-04-2024
This commit is contained in:
71
test_sqlite/action.php
Normal file
71
test_sqlite/action.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
//action.php
|
||||
// id, filename, lens, legende, copyright, title,creator,keywords
|
||||
|
||||
//include('database_connection.php');
|
||||
//print_r($_POST);
|
||||
/*
|
||||
*/
|
||||
//$_POST['action'] = 'delete';
|
||||
//$_POST['action'] = 'edit';
|
||||
/*
|
||||
$_POST["id"] = 179;
|
||||
|
||||
$_POST['lens'] = "";
|
||||
$_POST['legende'] = "cso";
|
||||
$_POST['copyright'] = "cso";
|
||||
$_POST['title'] = "cso";
|
||||
$_POST['creator'] = "";
|
||||
$_POST['keywords'] = "";
|
||||
*/
|
||||
$conn = new PDO('sqlite:../db_photo.sqlite3');
|
||||
|
||||
if($_POST['action'] == 'edit') {
|
||||
try {
|
||||
$data = array(
|
||||
':lens' => $_POST['lens'],
|
||||
':legende' => $_POST['legende'],
|
||||
':copyright' => $_POST['copyright'],
|
||||
':title' => $_POST['title'],
|
||||
':creator' => $_POST['creator'],
|
||||
':keywords' => $_POST['keywords'],
|
||||
':id' => $_POST['id']
|
||||
);
|
||||
|
||||
$query = "
|
||||
UPDATE photos
|
||||
SET lens = :lens,
|
||||
legende = :legende,
|
||||
copyright = :copyright,
|
||||
title = :title,
|
||||
creator = :creator,
|
||||
keywords = :keywords
|
||||
WHERE id = :id
|
||||
";
|
||||
// echo $query;
|
||||
// print_r($data);
|
||||
|
||||
$statement = $conn->prepare($query);
|
||||
$statement->execute($data);
|
||||
echo json_encode($_POST);
|
||||
}
|
||||
catch(PDOException $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if($_POST['action'] == 'delete') {
|
||||
$query = "
|
||||
DELETE FROM photos
|
||||
WHERE id = '".$_POST["id"]."'
|
||||
";
|
||||
$statement = $conn->prepare($query);
|
||||
$statement->execute();
|
||||
echo json_encode($_POST);
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user