Project

General

Profile

Bug #44752 » set-pids.php

Christian Bernet, 2013-02-22 08:38

 
<?php
//nur hier anpassen
$database = 'db';
$user = 'user';
$password = 'pw';

mysql_connect('localhost',$user,$password);
mysql_select_db($database);

//tt_content+image
$resultFileReference = mysql_query("select uid, uid_foreign from sys_file_reference where tablenames='tt_content' and fieldname='image'");
while ($rowFileReference = mysql_fetch_assoc($resultFileReference)) {
$resultContent = mysql_query("select uid, pid from tt_content where uid=".$rowFileReference['uid_foreign']);
$rowContent = mysql_fetch_assoc($resultContent);
$resultUpdate = mysql_query("update sys_file_reference set pid=".$rowContent['pid']." where uid=".$rowFileReference['uid']);
echo 'fileReference with uid: '.$rowFileReference['uid'].' is on page '.$rowContent['pid'].'/successful<br />';
}

//pages+media
$resultFileReference = mysql_query("select uid, uid_foreign from sys_file_reference where tablenames='pages' and fieldname='media'");
while ($rowFileReference = mysql_fetch_assoc($resultFileReference)) {
$resultUpdate = mysql_query("update sys_file_reference set pid=".$rowFileReference['uid_foreign']." where uid=".$rowFileReference['uid']);
echo 'fileReference with uid: '.$rowFileReference['uid'].' is on page '.$rowFileReference['uid_foreign'].'/successful<br />';
}

//pages_language_overlay+media
$resultFileReference = mysql_query("select uid, uid_foreign from sys_file_reference where tablenames='pages_language_overlay' and fieldname='media'");
while ($rowFileReference = mysql_fetch_assoc($resultFileReference)) {
$resultOverlay = mysql_query("select uid, pid from pages_language_overlay where uid=".$rowFileReference['uid_foreign']);
$rowOverlay = mysql_fetch_assoc($resultOverlay);
$resultUpdate = mysql_query("update sys_file_reference set pid=".$rowOverlay['pid']." where uid=".$rowFileReference['uid']);
echo 'fileReference with uid: '.$rowFileReference['uid'].' is on page '.$rowOverlay['pid'].'/successful<br />';
}
mysql_free_result($resultFileReference);
?>
(4-4/5)