[wp-hackers] WPDB does not seem to support RENAME TABLE query
jdg at codesymphony.co
Sun Sep 22 13:07:17 UTC 2013
Are you sure the user has the correct permissions? A search online for "wpdb rename table" (https://www.google.com/search?q=wpdb+rename+table) brings up code in several plugins that seem to have done this. I don't see anything that should stop it.
And what version of WordPress are you using? Those line number don't seem to match trunk or any of the recent versions (maybe trunk has changed since you posted this).
On Sep 21, 2013, at 7:02 PM, Paul Menard <paul at codehooligans.com> wrote:
> Maybe I'm missing something. Or maybe this is just an oversight on the wpdb class.
> When calling the SQL RENAME TABLE `table_source` TO `table_dest`;
> I get a PHP Warning: errno:2 mysql_fetch_object(): supplied argument is not a valid MySQL result resource /usr/local/www/htdocs/projects/Incsub/local.inc352-snapshot.com/wp-includes/wp-db.php on line 1225
> In looking at the wp-db.php code I see where it checks if the query is create, alter, truncate, drop (line 1212). This of course falls through.
> I know I have some options
> 1. Do my own direct mysql to handle the rename - But I want to try and keep this within WP. Plus it would mean a new DB connection.
> 2. Change the query from RENAME TABLE query to something like INSERT INTO `table_dest` SELECT * FROM `table_source`; DROP TABLE `table_source`; This also mean I need to add in the CREATE TABLE query. So seems like multiple steps instead of the clean RENAME TABLE.
> Anyone see what I'm missing? Is there are way to use RENAME TABLE within $wpdb ?
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
More information about the wp-hackers