Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Installing SilverStripe

Getting SilverStripe up and running on your computer and on your web server.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

lokal (win) -> remote (linux), problems


Reply

9 Posts   2622 Views

Avatar
steffik

6 April 2011 at 2:44am (Last edited: 6 April 2011 2:46am), Community Member, 15 Posts

wiping the database doesn't really sound like a good solution to me - and i think my client won't like the idea as well.

So i started writing that php script. I have very limited php skills, but this is what i have for now:

At the moment the str_replace(...) Function doesn't always lead to the correct result, but i'm not sure where that comes from...

<?php
$dbFileName = "dumpTest.sql";
$csvFileName = "TableNames.csv";

repairFile($dbFileName, $csvFileName);

function repairFile($dbFileName, $csvFileName) {
   $sqlFileHandle = fopen($dbFileName, "r");
   $contents = fread($sqlFileHandle, filesize($dbFileName));
   $csvFileHandle = fopen ($csvFileName,"r"); // Datei zum Lesen öffnen
   while ( ($data = fgetcsv ($csvFileHandle, 1000, ";")) !== FALSE ) {
      print $data[0].' -> '.$data[1].'<br>';
      $contents = str_replace($data[0], $data[1], $contents, $count);
      print $count.'<br>';
   }

   $sqlResultFileHandle = fopen($dbFileName, "w");
   
if (!fwrite($sqlResultFileHandle, $contents)) {
print "Can't write File $dbFileName";
exit;
}
   fclose($csvFileHandle);
   fclose($sqlFileHandle);
   fclose($sqlResultFileHandle);
}
   unset($contents, $sqlFileHandle, $csvFileHandle);
   unset($GLOBALS['contents'], $GLOBALS['sqlFileHandle'], $GLOBALS['csvFileHandle']);

?>