Add multiple columns in custom WordPress table if it does not exist -
this question has answer here:
- add new column wordpress database 3 answers
i make plug-in in word press , create tables, during upgrading plug-in need add columns existing table, want add columns table if not exist in table.how can ?
you can use query (change table name , column name)
$row = $wpdb->get_results( "select column_name information_schema.columns table_name = 'wp_customer_say' , column_name = 'say_state'" ); if(empty($row)){ $wpdb->query("alter table wp_customer_say add say_state int(1) not null default 1"); }
Comments
Post a Comment