Here is a pretty simple code :
$query = "RENAME TABLE myOldTableName TO myNewTableName";
$is_ok = mysql_query($query);
echo ($is_ok) ? "Rename OK" : "Rename aborted";
But it alwayls print “Rename aborted”.
I found on php.net :
When processing a RENAME TABLE query, PHP apparently always returns false,
no matter if the query was successfully processed or not.
I tried mysql_affected_rows, but not working..
Any idea to know if the rename worked or not ? (without another query like SELECT, or SHOW TABLES, etc).
Thanks !
Well, after many tests, here we are :
After all, RENAME TABLE seems to work fine. The comment on php.net is apparently wrong, and I went as wrong as him on my first tests.
I want to thank Fahim Parkar who put his finger on a solution, and Entropy and Leigh who offer me alternative 😉
Tell me if something seems wrong !