[TYPO3-english] Export / import tt_news

Kay Strobach typo3 at kay-strobach.de
Mon Sep 20 16:25:45 CEST 2010


Rightclick the pagetree > more or special options > export t3d

I had problem, because the file was to big, therefore i wrote a small
script, which makes a db connection from the new server to the old one
copies the files and rename them.
The script removes the categories :( - as i didn't need them.

you need to modify the path (below /dest/ and the db params).

--------------------------------------------------------------------------------------
<?php
die();
//set content-type
	header('Content-Type:text/plain');

//connect to database
	$src = new PDO('mysql:dbname=***;host=**','**','**');
	$dest= new PDO('mysql:dbname=***;host=**','**','**');

//set to utf8
	$src->query('set character set utf8');

//selecte entries
	$src_tt_news = $src->prepare('SELECT * FROM tt_news where deleted = 0
and category!=5');
	$src_tt_news->execute();
	$news_array  = $src_tt_news->fetchAll(PDO::FETCH_ASSOC);

//modify news
	foreach($news_array as $key=>$news) {
		unset($news['uid']);
		unset($news['category']);
		unset($news['tx_xmlttnewsimport_xmlunid']);
		$news['pid'] = 1430;
		$images = explode(',',$news['image']);
		foreach($images as $image) {
			/*
			copy(
				'http://www.server.de/uploads/pics/'.$image,
				'/dest/old-----'.$image
			);//*/
		}
		$news['image'] = 'bdd-----'.implode(',bdd-----',$images);
		$news_array[$key] = $news;
	}
	
//build insert query
	$fields =     implode(',' ,array_keys($news_array[0]));
	$values = ':'.implode(',:',array_keys($news_array[0]));
	$insert = $dest->prepare('
		INSERT INTO tt_news ('.$fields.') VALUES ('.$values.');
	');
	
//insert into database
	foreach($news_array as $news) {
		$insert->execute($news);
		#print_r($news);
		#print_r($insert->errorInfo());
		#die();
	}
//echo error info
	print_r($src_tt_news->errorInfo());

?>
------------------------------------------------------------------------------------------------------






Best regards
Kay

Am 20.09.2010 15:40, schrieb Pero Matic:
> "Kay Strobach" <typo3 at kay-strobach.de> wrote in message 
> news:mailman.1.1284989332.2117.typo3-english at lists.typo3.org...
>> Am 20.09.2010 15:24, schrieb Pero Matic:
>>> Hi. I need to export tt_news records from tt_news 2.5.2 and import this 
>>> into
>>> tt_news 3.0.1 which is in separate TYPO3 installation (i also need to do
>>> text recoding from iso-xxx to utf8 for old tt_news records). Can someone
>>> give me advice how to do this? Thx.
>>>
>>> Regards.
>>>
>>>
>>
>> I updated the old news to 3.0 and then transfered the date with a single
>> select and a couple of inserts ;)
> 
> Yep, i thought to do the same thing (update the old one). Is it possible to 
> make export via TYPO3 because there will be some references to images used 
> in news records? Thx.
> 
> Regards. 
> 
> 



More information about the TYPO3-english mailing list