I'm trying to import WordPress users and usermeta tables to my Laravel DB. So far, I've established connection to the WP database and now struggling to find the right way to join these tables. The table structure is as follows -
wp_users : Only listing required columns
ID | user_email
1 | [email protected]
2 | [email protected]
...
wp_usermeta : Only listing required columns
umeta_id | user_id | meta_key | meta_value
1 | 1 | first_name | John
2 | 1 | last_name | Travolta
3 | 1 | city | Phucket
4 | 2 | first_name| Patrick
5 | 2 | city | London
and so on. My aim is to get a result where I've all the user information available for importing, row-wise.
$builder = DB::connection('wp')->table('wp_users')->join('wp_usermeta', 'ID', '=', 'wp_usermeta.user_id')->select('*')->limit(500);
that's been my best attempt so far; but it's not giveing me the results I desire. Would really appreciate if someone could show me the right direction. Thanks!