<tfoot id='ib7Di'></tfoot>

      <small id='ib7Di'></small><noframes id='ib7Di'>

      • <bdo id='ib7Di'></bdo><ul id='ib7Di'></ul>
      <legend id='ib7Di'><style id='ib7Di'><dir id='ib7Di'><q id='ib7Di'></q></dir></style></legend>
    1. <i id='ib7Di'><tr id='ib7Di'><dt id='ib7Di'><q id='ib7Di'><span id='ib7Di'><b id='ib7Di'><form id='ib7Di'><ins id='ib7Di'></ins><ul id='ib7Di'></ul><sub id='ib7Di'></sub></form><legend id='ib7Di'></legend><bdo id='ib7Di'><pre id='ib7Di'><center id='ib7Di'></center></pre></bdo></b><th id='ib7Di'></th></span></q></dt></tr></i><div id='ib7Di'><tfoot id='ib7Di'></tfoot><dl id='ib7Di'><fieldset id='ib7Di'></fieldset></dl></div>

      Joomla 包含数据库功能

      时间:2023-10-16

      <small id='Njxfj'></small><noframes id='Njxfj'>

          <tbody id='Njxfj'></tbody>
        <i id='Njxfj'><tr id='Njxfj'><dt id='Njxfj'><q id='Njxfj'><span id='Njxfj'><b id='Njxfj'><form id='Njxfj'><ins id='Njxfj'></ins><ul id='Njxfj'></ul><sub id='Njxfj'></sub></form><legend id='Njxfj'></legend><bdo id='Njxfj'><pre id='Njxfj'><center id='Njxfj'></center></pre></bdo></b><th id='Njxfj'></th></span></q></dt></tr></i><div id='Njxfj'><tfoot id='Njxfj'></tfoot><dl id='Njxfj'><fieldset id='Njxfj'></fieldset></dl></div>
          • <legend id='Njxfj'><style id='Njxfj'><dir id='Njxfj'><q id='Njxfj'></q></dir></style></legend>

              <tfoot id='Njxfj'></tfoot>

                <bdo id='Njxfj'></bdo><ul id='Njxfj'></ul>

              • 本文介绍了Joomla 包含数据库功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我使用的是 Joomla 1.5.我创建了一个自定义组件,可以完美地从数据库中提取数据.我在我的主要组件文件中初始化数据库,如下所示:

                I'm using Joomla 1.5. I have created a custom component that pulls data out of the database perfectly. I initialize the database in my main component file like this:

                $db =& JFactory::getDBO();
                

                问题是我的组件页面上有一个 jQuery 自动完成插件,它从我的组件文件夹调用 PHP 文件.该 PHP 文件在数据库中搜索匹配结果,但我无法进行查询,因为我无法调用 $db =&JFactory::getDBO(); 因为这是一个自定义的 PHP 页面,我无法在没有任何引用的情况下访问这些函数.

                The problem is that I have a jQuery autocomplete plugin on my component page that makes calls to a PHP file from my component folder. That PHP file searches the database for matching results but I can't do the query because I can't call $db =& JFactory::getDBO(); because this is a custom PHP page and I can't access these functions without any references.

                谁能帮我在我的自定义文件中调用 Joomla 函数?

                Can anybody help me to call Joomla functions in my custom file ?

                谢谢.

                推荐答案

                我建议不要调用单独的 PHP 文件,而是在您的组件中使用 raw 视图格式.为此,请在您的组件中为 jQuery 将提取的数据创建一个视图.为了便于讨论,我们将此视图称为 autocomplete.像设置其他视图一样设置 autocomplete 视图,仅使用 view.raw.php 代替 view.html.php.然后在您的 JavaScript 中,调用 index.php?option=com_yourcomponent&view=autocomplete&format=raw.此 HTTP 调用只会返回您在视图中输出的内容.

                I would recommend not calling a separate PHP file and instead using the raw view format in your component. To do this, create a view in your component for the data that jQuery will be pulling. For discussion, we'll call this view autocomplete. Set up the autocomplete view as you would any other, only using view.raw.php in place of view.html.php. Then in your JavaScript, call index.php?option=com_yourcomponent&view=autocomplete&format=raw. This HTTP call will ONLY return what you output in your view.

                如果您绝对必须运行外部 PHP 文件,请查看使用 Joomla! 创建独立应用程序!框架:http://docs.joomla.org/How_to_create_a_stand-alone_application_using_the_Joomla%21_Framework足够的代码来拉入 JFactory 和数据库连接.但只有在您确实需要时才使用它:否则,您只是在创建另一个进入 Joomla! 的入口点!您必须维护和保护的应用程序.

                If you absolutely must run an external PHP file, take a look at creating a stand-alone application using the Joomla! Framework: http://docs.joomla.org/How_to_create_a_stand-alone_application_using_the_Joomla%21_Framework This is enough code to pull in JFactory and the database connection. But only use this if you really need to: otherwise, you are just creating another entry point into the Joomla! application that you will have to maintain and secure.

                您可能会发现 Louis Landry 关于执行 JSON 的帖子很有帮助:http://groups.google.com/group/joomla-dev-cms/browse_thread/thread/5ac0b49c0f458b1a

                You may find Louis Landry's post on doing JSON helpful: http://groups.google.com/group/joomla-dev-cms/browse_thread/thread/5ac0b49c0f458b1a

                我最近也写了关于这个话题的博客:http://www.designvsdevelop.com/the-way-not-to-do-javascript-in-joomla/

                I also blogged about this topic recently: http://www.designvsdevelop.com/the-way-not-to-do-javascript-in-joomla/

                这篇关于Joomla 包含数据库功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:显示 SQL 结果时 nl2br() 不起作用 下一篇:htaccess 将根重定向到子目录,但允许根和查询字符串中的 index.php 起作用

                相关文章

                    • <bdo id='VNDzR'></bdo><ul id='VNDzR'></ul>
                  1. <tfoot id='VNDzR'></tfoot>

                    <small id='VNDzR'></small><noframes id='VNDzR'>

                    <legend id='VNDzR'><style id='VNDzR'><dir id='VNDzR'><q id='VNDzR'></q></dir></style></legend>
                    <i id='VNDzR'><tr id='VNDzR'><dt id='VNDzR'><q id='VNDzR'><span id='VNDzR'><b id='VNDzR'><form id='VNDzR'><ins id='VNDzR'></ins><ul id='VNDzR'></ul><sub id='VNDzR'></sub></form><legend id='VNDzR'></legend><bdo id='VNDzR'><pre id='VNDzR'><center id='VNDzR'></center></pre></bdo></b><th id='VNDzR'></th></span></q></dt></tr></i><div id='VNDzR'><tfoot id='VNDzR'></tfoot><dl id='VNDzR'><fieldset id='VNDzR'></fieldset></dl></div>