简体   繁体   中英

Joomla 3.1.5 own module with database, sql ignore

I try create simple module for Joomla 3.1.5

Module in no problem install but code in sql install file is ignored. When I uninstall module uninstall script work.

My code in instalaction sql

CREATE TABLE IF NOT EXISTS `#__mylist_songs`(
`song_id` int(11) not null auto_increment PRIMARY KEY,
`name` varchar(255) not null,
`author` varchar(150) not null
)Engine=MyIsam  default charset=utf8;

CREATE TABLE IF NOT EXISTS `#__mylist_vote`(
`vote_id` int(11) not null auto_increment PRIMARY KEY,
`song_id` int(11) not null,
`ip` varchar(26),
`vote_date` datetime not null default '0000-00-00 00:00:00'
)Engine=MyIsam  default charset=utf8;

in module xml

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

        <filename module="mod_mylist">mod_mylist.php</filename>
        <filename>script.php</filename>
        <folder>tmpl</folder>
        <filename>helper.php</filename>
        <filename>index.html</filename>
        <filename>mod_mylist.xml</filename>
        <filename>sql/mysql/install.mysql.utf8.sql</filename>
        <filename>sql/mysql/uninstall.mysql.utf8.sql</filename>
        <folder>sql</folder>
        <folder>sql/mysql</folder>
        <folder>sql/mysql/updates</folder>
    </files>
    <scriptfile>script.php</scriptfile>

But after install module in DB is not change. When I have syntax error in uninstall sql script joomla show error but when the in install installation is done without errors.

I don't understand why. Path's are correct I checked it.

try this,

 <install>
            <sql>
                <file charset="utf8" driver="mysql">sql/mysql/install.sql</file>
            </sql>
        </install>
    <uninstall>
            <sql>
                <file charset="utf8" driver="mysql">sql/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. For more

Hope its helps..

Try using the following for your XML:

<files>
    <filename module="mod_mylist">mod_mylist.php</filename>
    <filename>index.html</filename>
    <filename>helper.php</filename>
    <folder>tmpl</folder>
    <folder>sql</folder>
</files>

I've removed references to the actual SQL files as they don't need to be defined if you're calling them in the <install> tag and clean up the rest of it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM