Joomla SQL数据库安装路径错误


joomla sql database install wrong path

我想为joomla创建一个简单的模块,在安装时将有和install.sql

所以我有这个xml文件:

<?xml version="1.0" encoding="utf-8"?>
<extension type="component" version="3.2.0" method="upgrade">
    <name>Address Api</name>
    <!-- The following elements are optional and free of formatting constraints -->
    <creationDate>August 2015</creationDate>
    <author>Tzook Bar Noy</author>
    <authorEmail>tbarnoy@xxxxxx.co.il</authorEmail>
    <authorUrl>http://www.xxxx.com</authorUrl>
    <copyright>Copyright Info</copyright>
    <license>License Info</license>
    <!--  The version string is recorded in the components table -->
    <version>0.0.1</version>
    <!-- The description is optional and defaults to the name -->
    <description>Description of the Hello World component ...</description>

    <files>
        <filename>addressapi.php</filename>
        <filename>ApiCall.php</filename>
        <filename>controller.php</filename>
        <filename>addressapi.xml</filename>
        <folder>site</folder>
        <folder>admin</folder>
    </files>

    <install> <!-- Runs on install -->
        <sql>
            <file driver="mysql" charset="utf8">sql/install.mysql.utf8.sql</file>
        </sql>
    </install>
    <uninstall> <!-- Runs on uninstall -->
        <sql>
            <file driver="mysql" charset="utf8">sql/uninstall.mysql.utf8.sql</file>
        </sql>
    </uninstall>
    <update> <!-- Runs on update; New since J2.5 -->
        <schemas>
            <schemapath type="mysql">sql/updates/mysql</schemapath>
        </schemas>
    </update>

    <administration>
        <!-- Administration Main File Copy Section -->
        <!-- Note the folder attribute: This attribute describes the folder
            to copy FROM in the package to install therefore files copied
            in this section are copied from /admin/ in the package -->

    </administration>

</extension>

,但当我做安装抛出扩展。我得到这个错误:

 JInstaller: :Install: SQL File not found /web/joom/administrator/components/com_addressapi/sql/install.mysql.utf8.sql

所以我的问题是,为什么它正在寻找管理员/组件文件夹内的SQL文件,而不是正常的组件??

我的文件夹和文件结构:

 com_addressapi
     admin
         models
             index.html
         sql
             update
             index.html
             install.mysql.utf8.sql
             uninstall.mysql.utf8.sql
         tables
             index.html
         addressapi.php
         index.html
     site
         addressapi.php
         index.html
     addressapi.xml
     addressapi.php
     ApiCall.php
     controller.php

您得到这个错误,因为您没有sql文件夹添加到您的manifest.xml文件。需要将该文件夹包含到manifest.xml文件中。

<folder>sql</folder> 

和你的sql文件夹应该有install.mysql.utf8.sqluninstall.mysql.utf8.sql所需的脚本写在那里。

MVC组件开发与适当的文件夹和清单文件结构:

具有:Joomla 2.5组件开发https://docs.joomla.org/J2.5: Developing_a_MVC_Component/Adding_an_install-uninstall-update_script_file

Joomla 3。x组件开发https://docs.joomla.org/J3.x: Developing_an_MVC_Component/Developing_a_Basic_Component

或者您可以使用组件创建器创建一个基本的Joomla组件,然后您可以根据需要更改它。

http://www.component-creator.com/en/