Project

General

Profile

Feature #12598 » askit-table-keys.php

Script to add primary key column to AskIt theme tables - Boone Gorges, 2020-04-02 04:59 PM

 
1
<?php
2

    
3
global $wpdb;
4

    
5
$cr_tables = $wpdb->get_col( "SHOW TABLES LIKE '%etcomment_rating%'" );
6
foreach ( $cr_tables as $cr_table ) {
7
	$query = "ALTER TABLE {$cr_table} ADD COLUMN etcommentrating_id bigint(20) unsigned NOT NULL auto_increment PRIMARY KEY";
8
	$wpdb->query( $query );
9
}
10

    
11
$ra_tables = $wpdb->get_col( "SHOW TABLES LIKE '%etright_answer%'" );
12
foreach ( $ra_tables as $ra_table ) {
13
	$query = "ALTER TABLE {$ra_table} ADD COLUMN etrightanswer_id bigint(20) unsigned NOT NULL auto_increment PRIMARY KEY";
14
	$wpdb->query( $query );
15
}
(3-3/9)