Webmaster Forum

Go Back   Webmaster Forum > Web Development > Coding Forum

Coding Forum Problems with your code? Discuss coding issues, including JavaScript, PHP & MySQL, HTML & CSS, Flash & ActionScript, and more.


Reply
 
Thread Tools Display Modes
Share |
  #1  
Old 01-02-2016, 01:08 PM
Czorny Czorny is offline
Contributing Member
 
Join Date: 03-21-12
Posts: 103
iTrader: 0 / 0%
MySQL issue - Drupal 7>WP4 migration

Code:
INSERT INTO wordpress.wp_posts (id, post_author, post_date, post_content, post_title, post_excerpt, post_name, post_modified, post_type, post_status) SELECT DISTINCT n.nid `id`, n.uid `post_author`, FROM_UNIXTIME(n.created) `post_date`, r.body_value `post_content`, r.body_summary `post_excerpt`, n.title `post_title`, r.body_summary `post_excerpt`, a.alias `post_name`, FROM_UNIXTIME(n.changed) `post_modified`, n.type `post_type`, IF(n.status = 1, 'publish', 'private') `post_status`, '', '', '', FROM node n, field_data_body r, url_alias a WHERE n.vid = r.entity_id AND a.source = CONCAT('node/', n.nid); UPDATE wordpress.wp_posts SET post_type = 'post' WHERE post_type <> 'page' OR post_type <> 'post';
Trying to execute Drupal-WP migration via SQL queries. Keep getting this:
Code:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM node n, field_data_body r, url_alias a WHERE n.vid = r.entity_id AND a.sou' at line 18
Googled a lot, but still can't see what's the problem here. Need help.

Can't say I've dealt much with MySQL before, so any hints on how I can execute simple migration of Drupal posts to WP via SQl queries will be really appreciated.
 
Reply With Quote

Advertisement

Advertisement

  #2  
Old 01-02-2016, 01:48 PM
Dan Williamson Dan Williamson is offline
The Controversial Coder
 
Join Date: 05-01-06
Location: Manchester; UK
Posts: 2,710
iTrader: 0 / 0%
Try:

PHP Code:
INSERT INTO wordpress.wp_posts (idpost_authorpost_datepost_contentpost_titlepost_excerptpost_namepost_modifiedpost_typepost_status)

SELECT DISTINCT
    n
.nid `id`,
    
n.uid `post_author`,
    
FROM_UNIXTIME(n.created) `post_date`,
    
r.body_value `post_content`,
    
r.body_summary `post_excerpt`,
    
n.title `post_title`,
    
r.body_summary `post_excerpt`,
    
a.alias `post_name`,
    
FROM_UNIXTIME(n.changed) `post_modified`,
    
n.type `post_type`,
    IF(
n.status 1'publish''private') `post_status`,
    
'',
    
'',
    
''
FROM node nfield_data_body rurl_alias a
WHERE n
.vid r.entity_id AND a.source CONCAT('node/'n.nid);
UPDATE wordpress.wp_posts
SET post_type 
'post'
WHERE post_type <> 'page' OR post_type <> 'post'
Unfortunately I don't have anywhere to test a quick DB migration from Drupal to Wordpress and I am primarily a T-SQL guy.
 
Reply With Quote
  #3  
Old 01-02-2016, 02:37 PM
Czorny Czorny is offline
Contributing Member
 
Join Date: 03-21-12
Posts: 103
iTrader: 0 / 0%
Unfortunately, your code returns:
#1136 - Column count doesn't match value count at row 1
- it seems, due to line 17's missing comma.

When with a comma at line 17, returns same error:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM node n, field_data_body r, url_alias a
WHERE n.vid = r.entity_id AND a.sou' at line 18
 
Reply With Quote
  #4  
Old 01-02-2016, 02:55 PM
Dan Williamson Dan Williamson is offline
The Controversial Coder
 
Join Date: 05-01-06
Location: Manchester; UK
Posts: 2,710
iTrader: 0 / 0%
I wouldn't have thought the comma would have caused a "Column count doesn't match value count at row 1" error, as the comma is causing the bad syntax if I recall my MySQL correctly, you don't specify a comma unless you are going to have another field.

That error is however infinitely more helpful, you seem to be selecting r.body_summary 'post_excerpt' twice. Maybe that could be the key? If you count your INSERT columns, there are 10, whereas in your SELECT statement you have defined 11, and the r.body_summary is duplicated.
 
Reply With Quote
  #5  
Old 01-02-2016, 03:14 PM
Czorny Czorny is offline
Contributing Member
 
Join Date: 03-21-12
Posts: 103
iTrader: 0 / 0%
Dan, yeah, I've done some strange duplication, but - you wont believe me - that wasn't the cause. The issue persists even after I've eliminated one of the two "r.body_summary..". MySQL returns absolutely identical messages - #1136 when without comma at line 17, #1064 when with it.
 
Reply With Quote
  #6  
Old 01-04-2016, 12:35 PM
Czorny Czorny is offline
Contributing Member
 
Join Date: 03-21-12
Posts: 103
iTrader: 0 / 0%
Update. This code worked and perfectly migrated nearly 1/3 of the content (hooo-*ucking-ray!):

PHP Code:
TRUNCATE TABLE wordpress.wp_comments;
TRUNCATE TABLE wordpress.wp_links;
TRUNCATE TABLE wordpress.wp_postmeta;
TRUNCATE TABLE wordpress.wp_posts;
TRUNCATE TABLE wordpress.wp_term_relationships;
TRUNCATE TABLE wordpress.wp_term_taxonomy;
TRUNCATE TABLE wordpress.wp_terms;
INSERT INTO wordpress.wp_posts
(idpost_authorpost_datepost_contentpost_titlepost_excerpt,
post_namepost_modifiedpost_typepost_status)
SELECT DISTINCT
n
.nid `id`,
n.uid `post_author`,
FROM_UNIXTIME(n.created) `post_date`,
r.body_value `post_content`,
r.body_summary `post_excerpt`,
n.title `post_title`,
a.alias `post_name`,
FROM_UNIXTIME(n.changed) `post_modified`,
n.type `post_type`,
IF(
n.status 1'publish''private') `post_status`
FROM node nfield_data_body rurl_alias a
WHERE n
.vid r.entity_id AND a.source CONCAT('node/'n.nid);
UPDATE wordpress.wp_posts
SET post_type 
'post'
WHERE post_type <> 'page' OR post_type <> 'post'
But now I'm getting another issue: phpMyAdmin's "Token Mismatch". Any thoughts how I can solve this, anybody?
 
Reply With Quote
  #7  
Old 01-04-2016, 12:41 PM
Dan Williamson Dan Williamson is offline
The Controversial Coder
 
Join Date: 05-01-06
Location: Manchester; UK
Posts: 2,710
iTrader: 0 / 0%
If you are using a shared webhost you may need to contact them with the Token Mismatch error.
 
Reply With Quote
  #8  
Old 01-04-2016, 12:47 PM
Czorny Czorny is offline
Contributing Member
 
Join Date: 03-21-12
Posts: 103
iTrader: 0 / 0%
Quote:
Originally Posted by Dan Williamson View Post
If you are using a shared webhost you may need to contact them with the Token Mismatch error.
No, I'm using local XAMPP at the moment, so open to suggestions
 
Reply With Quote
  #9  
Old 01-04-2016, 01:03 PM
Dan Williamson Dan Williamson is offline
The Controversial Coder
 
Join Date: 05-01-06
Location: Manchester; UK
Posts: 2,710
iTrader: 0 / 0%
Check your session.save_path in your PHP.ini file - it may be set wrong or have a ; before it in XAMPP - remove the ; and restart XAMPP.
 
Reply With Quote
  #10  
Old 01-04-2016, 01:13 PM
Czorny Czorny is offline
Contributing Member
 
Join Date: 03-21-12
Posts: 103
iTrader: 0 / 0%
Checked this before posting, stackoverflow rules No luck this far.

Update: clearing the /TMP removed the error msg, but the SQL query still returns only 1/3 of the needed result. Now that's strange

Last edited by Czorny; 01-04-2016 at 01:21 PM.
 
Reply With Quote
Go Back   Webmaster Forum > Web Development > Coding Forum

Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Web Programmer (PHP, MySQL , Drupal) available rndsllc Sell Web Services 0 07-18-2015 11:03 PM
mysql issue moving to vps apostars Coding Forum 1 08-21-2012 12:22 PM
mysql query performance issue gilbertsavier Coding Forum 1 08-04-2009 06:59 AM
[MySQL] Order By Issue Leon Coding Forum 2 07-13-2009 02:35 PM
mySQL Issue Sketch Coding Forum 8 01-17-2007 12:09 AM


V7N Network
Get exposure! V7N I Love Photography V7N SEO Blog V7N Directory


All times are GMT -7. The time now is 08:25 AM.
Powered by vBulletin
Copyright 2000-2014 Jelsoft Enterprises Limited.
Copyright © 2003 - 2018 VIX-WomensForum LLC