• Resolved Granit

    (@granit)


    We have changed our domain before we open the site and we got this code from the webhost that would help us change the old domain to the new one.

    We have created quite a lot of tables with images and links and was wondering if something similar would be possible with your plugin.

    This is what we run in phpmyadmin to change the url in posts and to images.

    UPDATE wp_posts SET guid = REPLACE (
    guid,
    'http://oldurl.com',
    'http://newurl.com');

    And then we run,

    UPDATE wp_posts SET post_content = REPLACE (
    post_content,
    'http://oldurl.com',
    'http://newurl.com');

    Would something like that be possible to run to change url in our tables?

    Thanks

    http://ww.wp.xz.cn/extend/plugins/tablepress/

Viewing 14 replies - 1 through 14 (of 14 total)
  • Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    thanks for your question.

    Basically, you can use exactly that code, as the tables are all stored in the wp_posts table in the database. The only change that you’ll have to make is to “escape” all slashes / with an extra backslash \, like

    UPDATE wp_posts SET post_content = REPLACE (
    post_content,
    'http:\/\/oldurl.com',
    'http:\/\/newurl.com');

    because that’s how the URLs are stored in the JSON format.

    Regards,
    Tobias

    Thread Starter Granit

    (@granit)

    Thank for the answer, whould i only run the one you posted or both as in my first post?
    Also, should i add www. before the url or just mysite.com?

    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    just this query is fine.
    And you would have to run the query for the same URL format as you are using it in tables, and how you want the new URL to be. The SQL query will do the exact replacement as in the query.

    Regards,
    Tobias

    Thread Starter Granit

    (@granit)

    I run it and it said that a number of lines where changed in the database.
    But i do not see any changes in the pages where the tables are.

    The images in the tables still have the address for the old domain.
    Strange.

    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    ah, that’s because the tables are still cached. When you view the site while you are logged-in into WordPress, everything should be working.
    If that is the case, you can clear the cache by removing some more entries from the database (which I will then tell you). If that however does not work, please check if the URLs where really changed by checking the URLs on the “Edit” screen of the table.

    Regards,
    Tobias

    Thread Starter Granit

    (@granit)

    Hi,

    I checked direct in the table edit now and the url is not changed.
    Any idea on what could work to get them changed?

    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    ok, and you are sure that you used the correct old URL in the replace command, and escaped all slashes?

    Regards,
    Tobias

    Thread Starter Granit

    (@granit)

    Yes, i used your code and only replaced the oldurl and newurl, should i have added something more?

    Thread Starter Granit

    (@granit)

    Just to be clear it is the image source link i am trying to change.

    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    ok, then I suggest that you investigate the raw format of the tables in the database, to see how the URLs look like there. For that, go to “wp_posts” in PHPMyAdmin and search for rows that have a “post_type” value of “tablepress_table”.
    It might be that some other characters besides the slash need espacing.

    Regards,
    Tobias

    Thread Starter Granit

    (@granit)

    I have been trying and cant get it to change.
    Here is how it looks in the database,

    <img src=\”http:\/\/www.bettools.se\/wp-content\/uploads\/2013\/02\/eu_flag.gif\” alt=\”\” width=\”30\” height=\”19\” class=\”alignnone size-full wp-image-517\” \/>

    Dont know what more to write in the database question in order for it to work.

    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    ok, then the old URL in the replace SQL should be

    http:\/\/www.bettools.se

    However, it might be possible that you have to double escape here, so please try

    http:\\/\\/www.bettools.se

    as the replace URL as well.

    Regards,
    Tobias

    Thread Starter Granit

    (@granit)

    That did the trick with the double escape.

    Thank you so much for the help, what i nightmare if we have had to change everything by hand.

    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    ah, good to hear that this worked! 🙂 Yes, mySQL is a little bit tricky when it comes to escaping.

    Best wishes,
    Tobias

    P.S.: In case you haven’t, please rate TablePress here in the plugin directory. Thanks!

Viewing 14 replies - 1 through 14 (of 14 total)

The topic ‘Changes in database’ is closed to new replies.