When does module_installer.php run?

tkott

Joined: 2010-06-07
Posts: 225
Posted: Sun, 2012-05-27 00:26

I'm developing a plugin for which I create a specific table. I had actually activated the plugin a couple times before creating the table, and I can't seem to make the module installer run.

I have the following files (assume my module name is xyz, in a folder modules/xyz/):

helpers/xyz_installer.php
- this file has a static function named "install" within a class called "xyz_installer"
- The table name is 'xyz_ids'

models/xyz_id.php
- This simply defines the class "xyz_id_Model" as an extension of "ORM".

I have other files, of course, but as I understand it, those should be the only ones I need to create the table. I deactivate and reactivate the module, but the table is not created. I've also tried deleting the only module variable from the database to no avail. Is there some cache that I need to delete for the installer to pick up?

Thanks!

----
Publish on Gallery 3 (WLPG Plugin) | XMP Module

 
tkott

Joined: 2010-06-07
Posts: 225
Posted: Sun, 2012-05-27 01:11

Ahh,

I think if you delete the row from the `modules` table, it will install on activation, or something like that. Either that or if you delete the module folder AND delete the row.

Clarification would still be appreicated!

----
Publish on Gallery 3 (WLPG Plugin) | XMP Module

 
jnash
jnash's picture

Joined: 2004-08-02
Posts: 814
Posted: Sun, 2012-05-27 01:21

deleting the row for your module out of the 'modules' table in your database should do the trick and trigger an 'install'

(as a side note, you can also do this in an 'activate' function inside the installer - check if table exists or not, then take appropriate action.)
(there is also "deactivate" that can be used to do something once you deactivate the module, as well as an 'uninstall', which I'm not sure when triggered...)

 
tkott

Joined: 2010-06-07
Posts: 225
Posted: Sun, 2012-05-27 01:48

@jnash -- now that idea with using the activate function (which I use anyway) to check for the table and install if necessary is smart!

Thanks for the confirmation.

----
Publish on Gallery 3 (WLPG Plugin) | XMP Module