Forums | Mahara Community
Developers
/
Help with plugin database tables
17 April 2012, 6:49
Hi,
Could anyone give me some tips or direct me to docs for creating a plugin with database tables which populates some of those tables with values on install?
I don't have a problem creating the db tables with install.xml, but I want to set up some look-up db tables with fixed values and I'm not having much luck with that, using upgrade.php or install.php in the db folder.
What is the 'official' approach for that?
Also, when I install my plugin I get an error like this:
[WAR] ba (lib/errors.php:745) Failed to get a recordset: mysql error: [1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '))' at line 1] in adodb_throw(DELETE FROM "artefact_installed_type" WHERE (plugin = 'mikesplugin' AND name NOT IN ()), )
[17-Apr-2012 12:29:03] [WAR] ba (lib/errors.php:745) Command was: DELETE FROM "artefact_installed_type" WHERE (plugin = ? AND name NOT IN ()) and values was (mikesplugin)
Once this has been thrown once, I can then successfully install the plugin. Am I missing something, or is this a quirk of my installation of Mahara?
Many thanks!
PS. Congrats to everyone responsible for releasing 1.5.
17 April 2012, 17:49
Hi Mike,
The 'official' approach is to use your plugin's postinst() function. If you search the code you'll find some examples.
R.
18 April 2012, 10:44
The error was due to the value in get_artefact_types() not being set....