//à vérifier //maybe_add_column creer une nouvelle table dans base de données function eme_create_payments_table($charset, $collate) { global $wpdb; $db_version = get_option('eme_version'); $table_name = $wpdb->prefix . PAYMENTS_TBNAME; if ($wpdb->get_var("SHOW TABLES LIKE '{$table_name}'") != $table_name) { $sql = "CREATE TABLE " . $table_name . " (\n id int(11) NOT NULL auto_increment,\n creation_date_gmt datetime NOT NULL DEFAULT '0000-00-00 00:00:00', \n booking_ids text NOT NULL,\n random_id tinytext NOT NULL,\n UNIQUE KEY (id)\n ) {$charset} {$collate};"; maybe_create_table($table_name, $sql); } else { maybe_add_column($table_name, 'random_id', "alter table {$table_name} add random_id tinytext NOT NULL;"); if ($db_version < 80) { $payment_ids = $wpdb->get_col("SELECT id FROM {$table_name}"); foreach ($payment_ids as $payment_id) { $random_id = eme_payment_random_id(); $sql = $wpdb->prepare("UPDATE {$table_name} SET random_id = %s WHERE id = %d", $random_id, $payment_id); $wpdb->query($sql); } } } } //ref: https://hotexamples.com/examples/-/-/maybe_create_table/php-maybe_create_table-function-examples.html#0xe2f57887ac08dc9ec44be0d664ce6dbe290246ce043f1c06fa34819c9ad5fd97-785,,804,