I am making a plugin for a client and i am trying to install it on their test server.
When i install the plugin locally, everything works fine. However, when i install it on their test server, the tables are not created. They don't have debug turned on, and i don't get any message that there was an error installing. I verify that the tables are not created, by using a plugin called database browser.
Here is the code, that creates the table, everything else is cut out. With this code the tables are created locally:
<?php
/*
Plugin Name: Integration Rating
*/
class IntegrationRating {
const INTEGRATIONS_TABLE_NAME = "ir_integrations";
const RATINGS_TABLE_NAME = "ir_ratings";
/**
* Called when the plugin is activated. Creates the tables for the plugin.
*/
public static function activate_plugin() {
global $wpdb;
$sqlCreateTable1 = "CREATE TABLE IF NOT EXISTS `" . $wpdb->prefix . IntegrationRating::INTEGRATIONS_TABLE_NAME . "` (
`post_id` bigint(40) unsigned NOT NULL,
`rating` int(11) NOT NULL,
`num_raters` int(11) NOT NULL,
PRIMARY KEY (`post_id`),
CONSTRAINT `post_id` FOREIGN KEY (`post_id`) REFERENCES `" . $wpdb->prefix . "posts` (`ID`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;";
$sqlCreateTable2 = "CREATE TABLE IF NOT EXISTS `" . $wpdb->prefix . IntegrationRating::RATINGS_TABLE_NAME . "` (
`post_id` bigint(40) unsigned NOT NULL,
`rater_email` varchar(255) NOT NULL DEFAULT '',
`rating` int(1) NOT NULL,
PRIMARY KEY (`post_id`,`rater_email`),
CONSTRAINT `ratings_post_id` FOREIGN KEY (`post_id`) REFERENCES `" . $wpdb->prefix . IntegrationRating::INTEGRATIONS_TABLE_NAME . "` (`post_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;";
$wpdb->query($sqlCreateTable1);
$wpdb->query($sqlCreateTable2);
}
/**
* Called when the plugin is uninstalled. Removes the plugins tables from the database.
*/
public static function uninstall_plugin() {
global $wpdb;
$sqlDropTable1 = 'DROP TABLE IF EXISTS ' . $wpdb->prefix . IntegrationRating::INTEGRATIONS_TABLE_NAME;
$sqlDropTable2 = 'DROP TABLE IF EXISTS ' . $wpdb->prefix . IntegrationRating::RATINGS_TABLE_NAME;
// Delete ratings first because of constraints
$wpdb->query($sqlDropTable2);
$wpdb->query($sqlDropTable1);
}
}
function ir_activate_plugin() {
IntegrationRating::activate_plugin();
}
function ir_uninstall_plugin() {
IntegrationRating::uninstall_plugin();
}
register_activation_hook(__FILE__, 'ir_activate_plugin');
register_uninstall_hook(__FILE__, 'ir_uninstall_plugin');
new IntegrationRating();
I'm hoping someone has some clues to what could be wrong.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire