I have two tables in my wordpress database.
$table_name1='objectives';
$table_name2='implementation-how';
Now I want to alter these tables.So I am using “dbDelta” function to alter these tables.My $table_name1 is altered successfully,but $table_name2 is not altering.Can anyone suggest what is I am missing.I am using following code
$table_name1='objectives';
$sql= "CREATE TABLE $table_name1 (
`objectiveID` int(11) unsigned NOT NULL AUTO_INCREMENT,
`catID` int(11) NOT NULL,
`objective` varchar(250) NOT NULL DEFAULT '',
`evalMeasure` varchar(250) NOT NULL DEFAULT '',
PRIMARY KEY (`objectiveID`)
) $charset_collate;";
dbDelta( $sql );
and
$table_name2='implementation-how';
$sql= "CREATE TABLE $table_name2 (
`howID` int(11) unsigned NOT NULL AUTO_INCREMENT,
`strategyID` int(11) NOT NULL,
`how` varchar(250) NOT NULL DEFAULT '',
ADD `is_default` int(11 ) NOT NULL DEFAULT '1',
ADD `userID` int(11),
PRIMARY KEY (`howID`)
) $charset_collate;";
dbDelta( $sql );
check this . when creating tables ,table name can’t use ‘-‘ symbols (reserved symbols)
use that code