-7

Currently i have a live e-commerce website which is i build with Wordpress and woocommerce. Since few months ago I start developing custom web application using php framework codeigniter. So now I have a plan to migrate my website (and all of the data) from Wordpress based Ecommerce -> to CodeIgniter web application.

Can you give me advice how to migrate all of the data since Wordpress database table & column is different with my CodeIgniter web app.

Any advice would be greatly appreciated.

Harkedian
  • 21
  • 3
  • Make a script to do it. – Alex Oct 24 '18 at 04:15
  • hi @Alex, can you elaborate more? how is it? – Harkedian Oct 24 '18 at 05:53
  • perform the task via a script. php or otherwise. download the database to localhost, connect to it, and make a script to do the migration taking the rows and moving the row column vals to the new table. that is as detailed as i can get for such a broad question. there is no 1 way to do it - and the 1 way best for you can vary greatly depending on your schema changes. – Alex Oct 24 '18 at 05:54

1 Answers1

0

Codeigniter have the capability to connect multiple databases, so in your config file add both database details in config/database.php:

$db['default'] = array(..); // here provide codeiginter database details
$db['wordpress'] = array(..); // here provide wordpress database details

Create a controller, lets call it Migration.php

class Migration extends CI_Controller {
    public function migrate(){
        $wordpress = $this->load->database('wordpress', TRUE);
        $users = $wordpress->get("users")->result();
        foreach($users as $user){
            // here change $user to whatever columns you have and insert to codeigniter database
            $user_add = array(
                'id' => $user->id,
                'firstName' => $user->first_name
                ....
            );
            $this->db->insert("users",$user_add);
        }
       // do for all tables same like above users table
    }
}
user969068
  • 2,818
  • 5
  • 33
  • 64