I have a mysql database of 100’s of tables. Some columns allow null value, some don’t.
I am inserting data into the table dynamically in php mysqli. I am using the following code to insert any null values:
$value = ($value == "") ? null : $value;
But, the problem with this is I am getting Column 'XXX' cannot be null error. How can I determine if the column supports Null values?
Please help.
You can get all information you need about database structure through the database
information_schema, like this one (you want the columnIS_NULLABLE):Reference:
http://dev.mysql.com/doc/refman/5.0/en/columns-table.html