Results 1 to 3 of 3

Thread: Though more Php then Contao, Replacing term TYPOlight in DB

  1. #1

    Default Though more Php then Contao, Replacing term TYPOlight in DB

    We have site as you must have seen long under showcases http://www.web-praesenz.ch.
    In whole of the website there are multiple occurance of word 'TYPOlight'. I wanted to have it replaced with word 'Contao', so I thought instead of replacing it one by one, why not per script.
    I set to write a script and almost done it with SQL some thing like
    Code:
    	foreach($tables as $table)
    	{
    			while($row = mysql_fetch_field($table))
    			{
    				$tn = $row->table;
    				$fn = $row->name;
    				$sql = "update $tn set $fn= replace($fn,'TYPOlight','Contao')"; 
    				mysql_query($sql);
    			}
    	}
    Yes it replaced every occurance of word 'TYPOlight'. Since many fields are serialized it didn't work well. I even thought for a while and changed the SQL syntex to
    Code:
    				$sql = "update $tn set $fn= replace($fn,'s:9:\"TYPOlight','s:6:\"Contao')";
    which didn't work. Any suggestion for a lazy man here.
    OM MANI PEME HUNG! how many has to die for freedom and dignity. Save this world

  2. #2
    User Toflar's Avatar
    Join Date
    06-19-09.
    Location
    Lyss, Switzerland
    Posts
    170

    Default Re: Though more Php then Contao, Replacing term TYPOlight in

    unserialize the data first an loop through the array? Maybe?

    Or make an sql dump, replace whatever needs to be replaced and import it back afterwards
    Regards

    Yanick - Contao core developer @terminal42 gmbh

  3. #3

    Default Re: Though more Php then Contao, Replacing term TYPOlight in

    Thanks for tips,
    Actually my first code worked well. On the places where it fails, which is only few of them (to my luck), i think I'll update it from the backend.
    unserialize the data first an loop through the array may be done, but I didn't do it thinking it is a lot of overhead.
    OM MANI PEME HUNG! how many has to die for freedom and dignity. Save this world

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •