100128_mensch.coop_repairDB.php 2.06 KB
<?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";
?>