WP Plugin won't create tables in Database
-
Hey,
i can’t figure out why my code to create 2 tables in the Database isn’t working.
Here’s the code:
<?php /* create tables for jQuery Maximage */ function jqmi_create_tables() { global $wpdb; $charset_collate = $wpdb->get_charset_collate(); require_once( ABSPATH.'wp-admin/includes/upgrade.php' ); $jqmi_image_paths = $wpdb->prefix.'jqmi_image_paths'; $jqmi_options = $wpdb->prefix.'jqmi_options'; // wp_jqmi_image_paths $jqmi_sql_one = "CREATE TABLE ".$jqmi_image_paths." ( id int(11) NULL AUTO_INCREMENT, path text NOT NULL, UNIQUE KEY id (id) ) $charset_collate;"; dbDelta( $jqmi_sql_one ); // wp_jqmi_options $jqmi_sql_two = "CREATE TABLE ".$jqmi_options." ( option text NOT NULL, value text NOT NULL, UNIQUE KEY option (id) ) $charset_collate;"; dbDelta( $jqmi_sql_two ); } register_activation_hook( __FILE__, 'jqmi_create_tables' ); /* initial information for wp_jqmi_options */ global $wpdb; $wpdb->insert( $wpdb->prefix.'jqmi_options', array( 'effect' => 'fade' ) ); ?>
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘WP Plugin won't create tables in Database’ is closed to new replies.