Answer the question
In order to leave comments, you need to log in
How to check for the existence of a table column?
Good afternoon!
I am writing a module for cms, the bottom line is that I need to add the htmlcolor column to the product table in sql at the first installation. It is important that when reinstalling the module, it does not erase this column.
I'm doing a PHP check, example:
$a = $this->db->query("SELECT htmlcolor FROM product");
if (!empty($a)) {
$this->db->query("ALTER TABLE product ADD `htmlcolor` VARCHAR( 6 ) NOT NULL");
}
Is everything correct? Or is there a better way?
Thanks :)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question