Quick question, is this query valid to run in PHP?
ALTER TABLE oldname RENAME newname;
To rename a table? So far everywhere I look says to run that in the MySQL monitor.
| SitePoint Sponsor |


Quick question, is this query valid to run in PHP?
ALTER TABLE oldname RENAME newname;
To rename a table? So far everywhere I look says to run that in the MySQL monitor.
So hold me when I'm here
Right me when I'm wrong
Hold me when I'm scared
Love me when I'm gone.

Never tried it, but anything you can run in mysql you should be able to run using PHP's mysql_query().


Yeah, except sometimes they do it differently. Like
USE database;
And
mysql_select_db('database');
So yeah, I was just wondering..
So hold me when I'm here
Right me when I'm wrong
Hold me when I'm scared
Love me when I'm gone.

Ah, I see. PHP's MySQL module doesn't have any built-in functions for renaming tables, so you'll want to use mysql_query() instead. You could probably use mysql_query() to select a database as well, but of course there's little reason to do so since the API provides a method for you.


Right, so
$DB->query("ALTER TABLE oldname RENAME newname");
ought to work, aye?
So hold me when I'm here
Right me when I'm wrong
Hold me when I'm scared
Love me when I'm gone.
Bookmarks