Problem with Setup method in Plugin
For some reason this code is not running correctly.
This is in a file called default.php in a plugin.
public function Setup() {
// Create db table. gc_cals (name,feedid, url,days)
$s = Gdn::Structure();
$s->Table('Cals')
->PrimaryKey('calID')
->Column('name', 'varchar(255)')
->Column('feedid', 'varchar(128)')
->Column('days', 'int(3)')
->Column('url', 'varchar(255)')
->Set(FALSE, FALSE);
$s->Insert('Cals', array(
'name' => 'This Weeks Games',
'feedid' => 'calgames',
'days' => 8,
'url' => 'group.calendar.google.com'
));
SaveToConfig('Plugins.GoogleCalendar.Enabled', TRUE);
}
This is in a file called default.php in a plugin.
0
Comments
Vanilla Forums COO [GitHub, Twitter, About.me]
The insert is there as is testing. In the final plugin there will be a way to configure it in the dashboard.
The table and record are not inserted whent he plugin is enabled.
define('DEBUG', TRUE);
Then try disable / enable the plugin and see if you have errors.
Vanilla Forums COO [GitHub, Twitter, About.me]
Nothing shows up on the debugger plugin either.
Currently running 2.011 (cant upgrade for a few weeks)
$Database = Gdn::Database(); $SQL = $Database->SQL();
Then you can do
$SQL->Insert( ... );
/** * These methods are invoked if present, but are not required and will be silently ignored * if they do not exist. */ // public function OnLoad() - Called as the plugin is instantiated (each page load) // public function OnDisable() - Called as the plugin is disabled // public function CleanUp() - Called as the plugin is removed
I can read the comments, but are these really working?
/cd
Removed the config settings and it now runs correctly. The problme was my previous version did not remove itself from the config settings.