joomla sql数据库安装错误的路径

时间:2015-08-18 06:16:35

标签: php joomla joomla3.0 joomla-extensions

我想为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

所以我的问题是,为什么要在administrator / complonents文件夹中查找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

1 个答案:

答案 0 :(得分:1)

您收到此错误是因为您没有将{s}文件夹添加到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/