100128_cleanAuthrisationsInDB.php
1.71 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
<?
require_once("../../../include/config.php");
$_LOSPDIR = $_LOSP_PATH_TO_ROOT = '../../../';
$_LOSP_DEV = false;
require_once("../../../include/System/php/RequireClass.inc.php");
$DB = StorableFactory::create($_LOSP_STORABLE_KINDOF, $_LOSP_STORABLE_DATA);
echo "\nrepair mensch.coop DB\n";
{
echo "* delete the losp_BasisElement_writeauthorisation entrys, where the ListID has not a losp_BasisElement entry \n ";
$stmt = $DB->PDO_query('select ListID, ProfileID, AuthWriteListID from losp_BasisElement_writeauthorisation left join losp_BasisElement on ListID=AuthWriteListID where ID is NULL');
if($stmt){
foreach($DB->PDO_fetchAll($stmt) as $row) {
$stmt = $DB->PDO_query('DELETE FROM losp_BasisElement_writeauthorisation WHERE ListID=:ListID and ProfileID=:ProfileID', array(':ListID' => $row['ListID'], ':ProfileID' => $row['ProfileID']));
$result = $DB->PDO_getResultRow($stmt);
echo '#'.$row['ListID'].'-'.$row['ProfileID'].'-'.$row['AuthWriteListID'].' ';
}
}
echo "\n => finish \n\n";
}
{
echo "* delete the losp_BasisElement_readauthorisation entrys, where the ListID has not a losp_BasisElement entry \n ";
$stmt = $DB->PDO_query('select ListID, ProfileID, AuthReadListID from losp_BasisElement_readauthorisation left join losp_BasisElement on ListID=AuthReadListID where ID is NULL');
if($stmt){
foreach($DB->PDO_fetchAll($stmt) as $row) {
$stmt = $DB->PDO_query('DELETE FROM losp_BasisElement_readauthorisation WHERE ListID=:ListID and ProfileID=:ProfileID', array(':ListID' => $row['ListID'], ':ProfileID' => $row['ProfileID']));
$result = $DB->PDO_getResultRow($stmt);
echo '#'.$row['ListID'].'-'.$row['ProfileID'].'-'.$row['AuthReadListID'].' ';
}
}
echo "\n => finish \n\n";
}
?>