]> git.mxchange.org Git - friendica.git/blob - include/dbclean.php
8ec9c1dc4a265c050d6fb50ed9dae0448085cf6b
[friendica.git] / include / dbclean.php
1 <?php
2 require_once("boot.php");
3
4 global $a, $db;
5
6 if(is_null($a))
7         $a = new App;
8
9 if(is_null($db)) {
10         @include(".htconfig.php");
11         require_once("include/dba.php");
12         $db = new dba($db_host, $db_user, $db_pass, $db_data);
13         unset($db_host, $db_user, $db_pass, $db_data);
14 }
15
16 load_config('config');
17 load_config('system');
18
19 update_shadow_copy();
20 killme();
21
22 function remove_orphans() {
23
24         logger("Deleting orphaned data from thread table");
25         q("DELETE FROM `thread` WHERE NOT EXISTS (SELECT `id` FROM `item` WHERE `item`.`parent` = `thread`.`iid`)");
26
27         logger("Deleting orphaned data from notify table");
28         q("DELETE FROM `notify` WHERE NOT EXISTS (SELECT `id` FROM `item` WHERE `item`.`id` = `notify`.`iid`)");
29
30         logger("Deleting orphaned data from sign table");
31         q("DELETE FROM `sign` WHERE NOT EXISTS (SELECT `id` FROM `item` WHERE `item`.`id` = `sign`.`iid`)");
32
33         logger("Deleting orphaned data from term table");
34         q("DELETE FROM `term` WHERE NOT EXISTS (SELECT `id` FROM `item` WHERE `item`.`id` = `term`.`oid`)");
35
36         logger("Done deleting orphaned data from tables");
37 }
38 ?>