Step 3 -- Compare recipes using the old format to recipes using the new format: (CompareTradeskillMethods.php)
PHP Code:
<?php
//Modify the following variables to match your database
$dbhost = "localhost";
$database = "projecteq";
$username = "databaseuser";
$password = "databasepass";
$timeout = 600; // in seconds
//stop editing here
set_time_limit($timeout);
$link = mysql_connect($dbhost, $username, $password)
or die('Could not connect: ' . mysql_error());
//First we get all of the old recipe_id information
$query = "SELECT DISTINCT recipe_id FROM `$database`.`tradeskill_recipe_entries` WHERE isnewrecipe=0;";
$result = mysql_query($query)
or die(mysql_error());
echo "<html>";
echo "<body>";
//Now we need to loop through all of those IDs we just got:
while($row = mysql_fetch_assoc($result)) {
$oldstring = "This is the old string.";
$newstring = "This is the new string.";
$recipeid = $row['recipe_id'];
//I realize this is a run on sentence, sue me.
$oldcomponents = "To make recipe #$recipeid (" . getRecipeName($recipeid, $database) . ") you need" . getRecipeComponents($recipeid, $database);
$newcomponents = "To make recipe #$recipeid (" . getRecipeName($recipeid, $database) . ") you need" . getRecipeComponents($recipeid, $database, true);
$oldcontainer = " inside item #" . getContainer($recipeid, $database);
$newcontainer = " inside item #" . getContainer($recipeid, $database, true);
$oldfails = " and if you fail you get back " . getOldFailures($recipeid, $database);
$newfails = " and if you fail you get back " . getNewFailures($recipeid, $database);
$oldsuccess = " but if you succeed you get back " . getOldSuccesses($recipeid, $database) . ".";
$newsuccess = " but if you succeed you get back " . getNewSuccesses($recipeid, $database) . ".";
$oldstring = $oldcomponents . $oldcontainer . $oldfails . $oldsuccess;
$newstring = $newcomponents . $newcontainer . $newfails . $newsuccess;
if ($oldstring == $newstring) {
if (!(strpos($oldstring, "an error") === false) && !(strpos($newstring, "an error") === false)) {
echo "<br />Error in recipe #$recipeid<br />";
echo "Old Method: $oldstring<br />";
echo "New Method: $newstring<br />";
}
}
else {
echo "<br />Recipe mismatch for recipe #$recipeid:<br />";
echo "Old Method: $oldstring<br />";
echo "New Method: $newstring<br />";
if (!($oldcomponents == $newcomponents)) {
echo "Mismatch in components:<br />";
echo "Old Method: $oldcomponents<br />";
echo "New Method: $newcomponents<br />";
}
if (!($oldcontainer == $newcontainer)) {
echo "Mismatch in container:<br />";
echo "Old Method: $oldcontainer<br />";
echo "New Method: $newcontainer<br />";
}
if (!($oldfails == $newfails)) {
echo "Mismatch in fails:<br />";
echo "Old Method: $oldfails<br />";
echo "New Method: $newfails<br />";
}
if (!($oldsuccess == $newsuccess)) {
echo "Mismatch in successes:<br />";
echo "Old Method: $oldsuccess<br />";
echo "New Method: $newsuccess<br />";
}
}
}
echo "End";
echo "</body>";
echo "</html>";
// ----Break for character limit -- See next post