Bug #45067 » set-pids.php

Christian Bernet, 2013-02-20 14:00

 
1
<?php
2
//nur hier anpassen
3
$database = 'db';
4
$user =  'user';
5
$password = 'pw';
6

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

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

    
19
//pages+media
20
$resultFileReference = mysql_query("select uid, uid_foreign from sys_file_reference where tablenames='pages' and fieldname='media'");
21
while ($rowFileReference = mysql_fetch_assoc($resultFileReference)) {
22
	$resultUpdate = mysql_query("update sys_file_reference set pid=".$rowFileReference['uid_foreign']." where uid=".$rowFileReference['uid']);
23
	echo 'fileReference with uid: '.$rowFileReference['uid'].' is on page '.$rowFileReference['uid_foreign'].'/successful<br />';
24
}
25
mysql_free_result($resultFileReference);
26
?>
(2-2/2)