-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug_activities.php
More file actions
31 lines (28 loc) · 1.13 KB
/
debug_activities.php
File metadata and controls
31 lines (28 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
require_once __DIR__ . '/config/db.php';
echo "Checking activities table...\n";
$pdo = db_connect();
$stmt = $pdo->query('SELECT * FROM activities');
$activities = $stmt->fetchAll();
echo "Count: " . count($activities) . "\n";
print_r($activities);
if (count($activities) === 0) {
echo "Table empty. Attempting seed...\n";
// Check if the seed logic in db_init_schema works or if we need to manually trigger it.
// db_init_schema is called on connection, so it SHOULD be populated.
// Maybe checking invalid file permission or path?
// Let's try to force insert.
$stmt = $pdo->prepare(
'INSERT INTO activities (title, description, activity_type, is_enabled)
VALUES (:title, :description, :activity_type, :is_enabled)'
);
$activities = [
['Speaking', 'Record audio...', 'speaking', 1],
['Writing', 'Write text...', 'writing', 1],
['Quiz', 'Multiple choice...', 'quiz', 1]
];
foreach($activities as $a) {
$stmt->execute(['title'=>$a[0], 'description'=>$a[1], 'activity_type'=>$a[2], 'is_enabled'=>$a[3]]);
}
echo "Forced insertion done.\n";
}