Php 乔姆拉JJ工厂选择

Php 乔姆拉JJ工厂选择,php,joomla,Php,Joomla,我有以下代码试图从表中获取数据: <?php define( '_JEXEC', 1 ); define( 'JPATH_BASE', realpath(dirname(__FILE__).'/../../' )); require_once ( $_SERVER['DOCUMENT_ROOT'].'/xampp/hobbies/includes/defines.php' ); require_once ( $_SERVER['DOCUMENT_ROOT

我有以下代码试图从表中获取数据:

<?php
    define( '_JEXEC', 1 );
    define( 'JPATH_BASE', realpath(dirname(__FILE__).'/../../' ));  
    require_once ( $_SERVER['DOCUMENT_ROOT'].'/xampp/hobbies/includes/defines.php' );
    require_once ( $_SERVER['DOCUMENT_ROOT'].'/xampp/hobbies/includes/framework.php' );

    $db =& JFactory::getDbo();
    $query = $db->getQuery(true);
    $query = 'SELECT * FROM vftd8_community_events';

    $db->setQuery($query,0,30);

    $results = $db->loadObjectList();
    if ($db->getErrorNum()) {
         echo $db->getErrorMsg();
         exit;
    }

    return (array) $results;
?>

结果集为空,表中有数据。它不会返回错误。 求你了,我需要帮助。谢谢大家。


<?php
// No direct access to this file
defined('_JEXEC') or die;

$db=Jfactory::getDBO();

$select='select * from `#__community_events` ';
$db->setQuery($select);

$res=$db->loadObjectList(); // for multiple records
//$product_data=$db->loadObject(); // for single row records

foreach ($res as $result)
{
   echo $result->id;
   // and whatever you need to print here
}
?>

该代码的结果与我的旧代码相同,问题是否可能来自up?。我没有像模块一样使用代码,我没有helper.php、modulename.php和.xml文件。我正在使用.js主模板文件(测试)中的ajax,调用我昨天共享的唯一的.php文件。这可能是我的问题的原因吗?非常感谢。它起作用了!,正在复制模块filosophy,非常感谢。如果您得到答案,请批准。我建议您使用JoomlaAPI中的适当子句,而不是像这样编写原始SQL查询。