100128_mensch.coop_repairDB.php
2.06 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
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_BasisClipboard entrys, where the PartOfID has not a losp_BasisElement entry \n ";
$stmt = $DB->PDO_query('select PartOfID from losp_BasisClipboard left join losp_BasisElement on PartOfID=ID where ID is NULL');
if($stmt){
foreach($DB->PDO_fetchAll($stmt) as $row) {
$stmt = $DB->PDO_query('DELETE FROM losp_BasisClipboard WHERE PartOfID=:PartOfID', array(':PartOfID' => $row['PartOfID']));
$result = $DB->PDO_getResultRow($stmt);
echo '#'.$row['PartOfID'].' ';
}
}
echo "\n => finish \n\n";
}
{
echo "* delete the losp_BasisClipboard entrys, where the AttachID has not a losp_BasisElement entry \n ";
$stmt = $DB->PDO_query('select AttachID from losp_BasisClipboard left join losp_BasisElement on AttachID=ID where ID is NULL');
if($stmt){
foreach($DB->PDO_fetchAll($stmt) as $row) {
$stmt = $DB->PDO_query('DELETE FROM losp_BasisClipboard WHERE AttachID=:AttachID', array(':AttachID' => $row['AttachID']));
$result = $DB->PDO_getResultRow($stmt);
echo '#'.$row['AttachID'].' ';
}
}
echo "\n => finish \n\n";
}
{
echo "* delete the losp_BE_topic entrys, where the MTextID has not a losp_BasisElement entry \n ";
$stmt = $DB->PDO_query('select MTextID, Name from losp_BE_topic left join losp_BasisElement on MTextID=ID where ID is NULL');
if($stmt){
foreach($DB->PDO_fetchAll($stmt) as $row) {
$stmt = $DB->PDO_query('DELETE FROM losp_BE_topic WHERE MTextID=:MTextID', array(':MTextID' => $row['MTextID']));
$result = $DB->PDO_getResultRow($stmt);
echo '#'.$row['MTextID'].'-'.$row['Name'].' ';
}
}
echo "\n => finish \n\n";
}
echo "* sql orders (100128_mensch.coop_repairDB.sql): INSERT INTO profile 3 and alter tables ....... \n ";;
$DB->transformFileToDatabase("100128_mensch.coop_repairDB.sql");
echo "\n\n";
?>