Copyright Info License Info

It is also often used to find rows in the database. Another field – greeting. It stores the greeting, which will return our request. Texts of our queries will be stored in a file install.sql Creating a uninstall.sql While we hope that people will never remove our component, but still if they do, we should not leave anything behind. Joomla controls Remove all generated files and folders, but we have to manually turn on the queries that will remove, we have created a database table. At this point we have created only one table.

And we only need one query: drop table if exists # __hello; Update installation file We need to make some changes to the setup file. First, we must add two new files to the list. File install.sql must navigate to admin. Secondly, we must point the installer to perform queries in our files during the installation and uninstallation. The updated code looks like this: version = '1 .0 'encoding =' utf-8 '?> Type =' component 'version = '1 .5.0'> Hello 2007-02-22 John Doe john.doe @ example.org Copyright Info License Info 3.01 Description of the component folder = 'site'> controller.php hello.php index.html models / hello.php models / index.html views / index.html views / hello / index.html views / hello / view.html.php views / hello / tmpl / default.php views / hello / tmpl / index.html charset = 'utf8' driver = 'mysql'> install.sql -> drop table if exists # __hello; create table # __hello (id int (11) not null auto_increment, greeting varchar (25) not null, primary key (id)) engine = MyISAM AUTO_INCREMENT = 0; insert into # __hello (greeting) values ('Hello, World!'), ('Bonjour, Monde!'), (' Ciao, Mondo! '); charset =' utf8 'driver =' mysql '> uninstall.sql -> drop table if exists # __hello; Hello World! folder = 'admin'> hello.php index.html install.sql uninstall.sql As you can see, the tag, which is located in the sections has two attributes: charset and driver. Charset encoding of this file.

Typically used utf-8. But if you want create installation files in a different encoding (eg for older versions MySQl) you should omit this attribute. Attribute specifies the driver for a database written requests. Currently, as the database can be only use MySql, but the future is supposed to create drivers for other databases. Conclusion Now that our component can work not only with classes mvc framework, but also with classes JDatabase. Now you can create components that interact with the database and can use the Joomla installer to create and populate database tables.