-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcheck_tables.php
More file actions
47 lines (40 loc) · 1.65 KB
/
check_tables.php
File metadata and controls
47 lines (40 loc) · 1.65 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
require_once '/var/www/html/lib/base.php';
$db = \OC::$server->getDatabaseConnection();
// Get all tables that contain 'softwarecatalog' or 'catalog'
$query = $db->getQueryBuilder();
$query->select('TABLE_NAME')
->from('information_schema.TABLES')
->where($query->expr()->eq('TABLE_SCHEMA', $query->createNamedParameter('nextcloud')))
->andWhere($query->expr()->orX(
$query->expr()->like('TABLE_NAME', $query->createNamedParameter('%softwarecatalog%')),
$query->expr()->like('TABLE_NAME', $query->createNamedParameter('%catalog%'))
));
try {
$result = $query->execute();
$tables = [];
while ($row = $result->fetch()) {
$tables[] = $row['TABLE_NAME'];
}
if (empty($tables)) {
echo "No tables found containing 'softwarecatalog' or 'catalog'" . PHP_EOL;
// Let's check for any tables that might be related
$query2 = $db->getQueryBuilder();
$query2->select('TABLE_NAME')
->from('information_schema.TABLES')
->where($query2->expr()->eq('TABLE_SCHEMA', $query2->createNamedParameter('nextcloud')))
->andWhere($query2->expr()->like('TABLE_NAME', $query2->createNamedParameter('%object%')));
$result2 = $query2->execute();
echo "Tables containing 'object':" . PHP_EOL;
while ($row = $result2->fetch()) {
echo "- " . $row['TABLE_NAME'] . PHP_EOL;
}
} else {
echo "Found tables:" . PHP_EOL;
foreach ($tables as $table) {
echo "- " . $table . PHP_EOL;
}
}
} catch (Exception $e) {
echo "Error: " . $e->getMessage() . PHP_EOL;
}