Medoo
Medoo copied to clipboard
ALTER TABLE issue on $db->query()
Hey there,
I tried to change a column type from INT to VARCHAR and I used this command, but I got no result/error.
$db->query("ALTER TABLE tablename CHANGE balance balance VARCHAR(300) NOT NULL;");
Would you please help me out?
Thanks.
Make sure your query is correct.
/* MySQL */
ALTER TABLE table_name RENAME COLUMN old_name TO new_name;
/* MariaDB */
ALTER TABLE table_name CHANGE COLUMN old_name TO new_name;
The above answer is supported on MySQL 8.0.
Just make sure the database can execute the query successfully based on the version. Because query() is just executing the query alone for the database.