Setting a wordpress project to its staging environment, I have ran into an issue regarding paths that were set for the development environment, and don’t fit the ones in staging.
So I need to update the paths in the database, from C:\xampp\htdocs\site.com to /var/www/site.com
At first, I tried replacing, the same way I replaced the urls:
update `wp_slider` set `url` = replace(`url`, 'http://local.', 'http://');
Then the paths:
update `wp_slider` set `path` = replace(`path`, 'C:\xampp\htdocs\site.com', '/var/www/site.com');
Which actually didn’t work. Then I tried a SELECT to see what rows can I retrieve:
SELECT * FROM `wp_slider` WHERE `path` LIKE "%C:\xampp\htdocs\site.com%"
Which will return an empty result. What am I missing?
Forgot to mention, that I tried escaping the \ by doing \\ and I still get no result
A full path of what I’m trying to replace would be like: C:\xampp\htdocs\site.com/wp-content/plugins/slider/skins/slider\circle\circle.css
That’s roughly the way to go:
If you get zero matches that’s because your DB records do not contain what you think they do. Make sure you don’t have blanks or control characters. If your MySQL client does not make it easy to spot such things, you can always use
HEX():Additionally, I’m not fully sure you can use
\as path separator in Unix systems. I suggest you replace it as well:Update:
What I’m trying to explain is that your procedure is basically correct (except that escaping
\is not always optional):If you don’t get matches it’s because your database contains different data than you think, such as (but not restricted to) whitespace or control characters:
In this last example, we forgot to escape
\when inserting and as a result we don’t get a match when replacing because the input data is not what we thought it was.