How to convert .sql file to fit my db's different structure?

Discussion in 'PHP' started by dherald, Dec 19, 2010.

  1. #1
    Hi everyone,

    So I have a .sql file but it's not for my db's structure. Can anyone help convert it so that it fits my structure?

    INSERT INTO `{tbl_prefix}files` (`fileid`, `file`, `icon`, `filelocation`, `iconlocation`, `customcode`, `title`, `description`, `keywords`, `width`, `height`, `category`, `timesplayed`, `status`, `filetype`, `dateadded`, `rating`, `totalvotes`, `totalvotepoints`, `added_by`, `adult`, `scores`, `score_type`) VALUES 
    ('', 'on-1.swf', 'on-1.png', 1, 1, '', 'Ski Run', 'Ski between the flags', 'Ski Run', 500, 380, 6, 0, '{status}', 'SWF', '{date_added}', 0.00, 0, 0, 0, '0', '0', '1'),
    Code (markup):
    That is the start of the SQL file and there are 100 rows below that that also get inserted.

    However, here is my DB structure:

    
    INSERT INTO `a_games` (`id`, `name`, `description`, `url`, `category_id`, `hits`, `published`, `user_submit`, `width`, `height`, `image`, `import`, `filetype`, `instructions`, `mochi`, `rating`, `featured`, `date_added`, `advert_id`, `highscores`, `mochi_id`) VALUES
    (9, 'Zombie Creator', 'Turn yourself into a creepy horror zombie!', '/games/Zombie-Creator.swf', '1', 5, 1, '0', '700', '500', '/games/images/Zombie-Creator.jpg', '0', '1', 'Upload a photo of yourself and drag and drop gorey images to create the most horrible zombie!', 1, '0.0', 0, '0000-00-00 00:00:00', 3, 0, 'dbf09e29d5073579'),
    
    Code (markup):
    Can anyone help convert the first structure so it fits the second one?

    Thanks!
     
    dherald, Dec 19, 2010 IP
  2. underground-stockholm

    underground-stockholm Guest

    Messages:
    53
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Here's a good start (too lazy to solve all of it..):

    $arr = explode(',', $str);
    $str2 = "INSERT INTO `a_games` (`id`, `name`, `description`, `url`, `category_id`, `hits`, `published`, `user_submit`, `width`, `height`, `image`, " .
            "`import`, `filetype`, `instructions`, `mochi`, `rating`, `featured`, `date_added`, `advert_id`, `highscores`, `mochi_id`) VALUES (0, " .
            $arr[28] . "," . $arr[29] . ",";
    echo $str2 . "\n";
    PHP:
     
    underground-stockholm, Dec 19, 2010 IP