Search code examples
mysqljoomlajcomponentsql-view

How to add sql view in setup file of joomla component


I am developing a joomla component. I need to import a sql view in my project.

create view view_name as select * from my_table


Solution

  • How you tried in your xml file add something like

    <install>
            <sql>
                <file charset="utf8" driver="mysql">install.sql</file>
            </sql>
        </install>
    <uninstall>
            <sql>
                <file charset="utf8" driver="mysql">uninstall.sql</file>
            </sql>
        </uninstall>
    

    And the install.sql file should have the query. Also make sure the DB user have permission to add new tables.

    Its Done!