06-04-2024

This commit is contained in:
2024-04-06 11:55:24 +02:00
parent f7c5cf7d47
commit 3d22f9c5d8
550 changed files with 27249 additions and 2537 deletions

80
test_sqlite/fetch.php Normal file
View File

@@ -0,0 +1,80 @@
<?php
//fetch.php
// id, filename, lens, legende, copyright, title,creator,keywords
$column = array("id", "filename", "lens", "legende", "copyright", "title", "creator", "keywords");
$query = "SELECT * FROM photos ";
if(isset($_POST["search"]["value"]))
{
$query .= '
WHERE filename LIKE "%'.$_POST["search"]["value"].'%"
OR lens LIKE "%'.$_POST["search"]["value"].'%"
OR speed LIKE "%'.$_POST["search"]["value"].'%"
';
}
if(isset($_POST["order"]))
{
$query .= 'ORDER BY '.$column[$_POST['order']['0']['column']].' '.$_POST['order']['0']['dir'].' ';
}
else
{
$query .= 'ORDER BY id DESC ';
}
$query1 = '';
if($_POST["length"] != -1)
{
$query1 = 'LIMIT ' . $_POST['start'] . ', ' . $_POST['length'];
}
$conn = new PDO('sqlite:../db_photo.sqlite3');
$stmt = $conn->prepare($query);
$stmt->execute();
$res = $stmt->fetchAll();
$number_filter_row = count($res);
$stmt = $conn->prepare($query . $query1);
$stmt->execute();
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
$data = array();
foreach($result as $row) {
$sub_array = array();
$sub_array[] = $row['id'];
$sub_array[] = $row['filename'];
$sub_array[] = $row['lens'];
$sub_array[] = $row['legende'];
$sub_array[] = $row['copyright'];
$sub_array[] = $row['title'];
$sub_array[] = $row['creator'];
$sub_array[] = $row['keywords'];
$data[] = $sub_array;
}
// id, filename, lens, legende, copyright, title,creator,keywords
function count_all_data($connect) {
$connect = new PDO('sqlite:../db_photo.sqlite3');
$query = "SELECT * FROM photos";
$statement = $connect->prepare($query);
$statement->execute();
return $statement->rowCount();
}
$output = array(
'draw' => intval($_POST['draw']),
'recordsTotal' => count_all_data($conn),
'recordsFiltered' => $number_filter_row,
'data' => $data
);
echo json_encode($output);
?>