100208_deleteDoubleFriendListBCs.php 2.47 KB
<?
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);
$HostAccount = BasisElement::createNewInstance($DB, 'Account', 0, $param_PartOf=null);

$var_PartOfObjVarID = 6;	//	FriendList
$var_CategoryID = 0;		//	''
$var_AttachStateID = 4;		//	unconfirmed

echo "\nrepair: delete double Friendlist BasisClipboards\n \t08.02.2010 @f\n";

$stmt = $DB->PDO_query(	'select distinct PartOfID, AttachID from losp_BasisClipboard where PartOfObjVarID=:PartOfObjVarID and CategoryID=:CategoryID',
array(':PartOfObjVarID' => $var_PartOfObjVarID, ':CategoryID' => $var_CategoryID)
);
if($stmt){
	foreach($DB->PDO_fetchAll($stmt) as $row) {
			
		$stmt2 = $DB->PDO_query(	'select * from losp_BasisClipboard where PartOfObjVarID=:PartOfObjVarID and CategoryID=:CategoryID and PartOfID=:PartOfID and AttachID=:AttachID',
		array(':PartOfObjVarID' => $var_PartOfObjVarID, ':CategoryID' => $var_CategoryID, ':PartOfID' => $row['PartOfID'], ':AttachID' => $row['AttachID']));
		$result_entrys = $DB->PDO_fetchAll($stmt2);
		if(count($result_entrys)==2) {
			echo ('* :PartOfID => '. $row['PartOfID']. '       :AttachID => '.  $row['AttachID']." \n");
			if($result_entrys[0]['AttachStateID'] ==3 && $result_entrys[1]['AttachStateID'] ==4 ) {
					
				$var_deleteQuery = 'delete from losp_BasisClipboard where PartOfObjVarID=:PartOfObjVarID and CategoryID=:CategoryID and PartOfID=:PartOfID and AttachID=:AttachID and AttachStateID=:AttachStateID';
				$var_deleteBindValues = array(':PartOfObjVarID' => $var_PartOfObjVarID, ':CategoryID' => $var_CategoryID, ':PartOfID' => $row['PartOfID'], ':AttachID' => $row['AttachID'], ':AttachStateID' => $var_AttachStateID);

				$stmt2 = $DB->PDO_query($var_deleteQuery, $var_deleteBindValues);
				$result = $DB->PDO_getResultRow($stmt2);

				echo("\t * delete from losp_BasisClipboard where PartOfObjVarID=".$var_PartOfObjVarID." and CategoryID=".$var_CategoryID." and PartOfID=".$row['PartOfID']." and AttachID=".$row['AttachID']." and AttachStateID=".$var_AttachStateID." => ".$result."\n");
			} else {
				echo "!!!!!!!!! Das kann doch gar nicht sein !!!!!!!!!!!! \t *".$result_entrys[0]['AttachStateID']." -- ".$result_entrys[1]['AttachStateID']."\n";
			}


		} else if(count($result_entrys)>2) {
			echo "!!!!!!!!! Das kann doch gar nicht sein !!!!!!!!!!!!";
		}

	}
}
echo "\n  => finish \n\n";


?>