Is it possible in joomla install.xml file write some sql, which would be executed on install? Or somehow else do this trick? The point is that i have written custom authorization plug-and i have to disable/replace/delete an existing one.
You could use external SQL-files and make them execute on install.
1. Create a SQL-file install.mysql.utf8.sql in your plugin root with some content like:
CREATE TABLE IF NOT EXISTS `#__tablename` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=0 ;
2. In your XML-manifest add the file as a filename node underneath files:
<files>
<filename>install.mysql.utf8.sql</filename>
</files>
3. Add a install node in your manifest that tells Joomla what SQL file to execute on installation:
<install>
<sql>
<file driver="mysql" charset="utf8">install.mysql.utf8.sql</file>
</sql>
</install>
If you install the plugin with this and it's a new installation (the plugin havn't been installed on the site before) then Joomla will execute the SQL-file.
If you need to execute SQL on a upgrade (reinstallation) of the plugin you'd have to use the update node.
An alternative to SQL-files is to use PHP-scripts to be executed (which can run SQL queries themselves) on install/update. For help with that, see this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With