Updated SQL File to remove dummy data.
This commit is contained in:
19
get_data.php
Normal file
19
get_data.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
require 'db.php';
|
||||
|
||||
$projects = $pdo->query("SELECT * FROM projects ORDER BY sort_order ASC")->fetchAll();
|
||||
|
||||
foreach ($projects as &$project) {
|
||||
$stmt = $pdo->prepare("SELECT * FROM tasks WHERE project_id = ? ORDER BY created_at");
|
||||
$stmt->execute([$project['id']]);
|
||||
$project['tasks'] = $stmt->fetchAll();
|
||||
|
||||
foreach ($project['tasks'] as &$task) {
|
||||
$stmt = $pdo->prepare("SELECT * FROM subtasks WHERE task_id = ? ORDER BY created_at");
|
||||
$stmt->execute([$task['id']]);
|
||||
$task['subtasks'] = $stmt->fetchAll();
|
||||
}
|
||||
}
|
||||
|
||||
echo json_encode($projects);
|
||||
?>
|
||||
Reference in New Issue
Block a user