tablename = $tablename; $this->dbtable = $wpdb->prefix.$this->tablename; if ($this->install()) { $this->add_recipe_data(); } } function install() { //$firephp = FirePHP::getInstance(true); //$firephp->log('database.php', 'install'); global $wpdb; if ($wpdb->get_var("show tables like '$this->dbtable'") != $this->dbtable) { $sql = "CREATE TABLE ".$this->dbtable." ( id mediumint(9) NOT NULL AUTO_INCREMENT, slug text NOT NULL, recipe_name text NOT NULL, recipe_url text, summary text, ingredients text, instructions text, quicknotes text, variations text, preparation_time int, recipe_type text, number_of_servings int, diet_type text, diet_restriction text, diet_other text, culinary_tradition text, rating int, UNIQUE KEY id (id) );"; require_once (ABSPATH.'wp-admin/includes/upgrade.php'); dbDelta($sql); return true; } } function remove() { global $wpdb; if ($this->drop_table) { $this->drop_recipe_table(); } } function drop_recipe_table() { //$firephp = FirePHP::getInstance(true); //$firephp->log($this->dbtable, 'drop_recipe_table'); global $wpdb; $wpdb->query("DROP TABLE ".$wpdb->prefix."recipetable"); //$firephp->log($this->dbtable, 'drop_recipe_table'); } function add_recipe_data() { /* $firephp = FirePHP::getInstance(true); $firephp->log('Add Recipe Data', 'add_recipe_data'); $firephp->log($this->dbtable, 'add_recipe_data'); */ global $wpdb; // Stick something in the database to display on the options page. $dbdata = array('id' => 1, 'slug' => 'blue-corn-pozole', 'recipe_name' => 'Blue Corn Pozole'); $wpdb->insert($this->dbtable, $dbdata); //$firephp->log($dbdata, 'add_recipe_data'); $dbdata = array('slug' => 'garlic-ancho-soup', 'recipe_name' => 'Garlic Ancho Soup'); $wpdb->insert($this->dbtable, $dbdata); //$firephp->log($dbdata, 'add_recipe_data'); } } ?>