简体   繁体   English

Joomla JFactory选择

[英]Joomla JFactory Select

I have this code trying to get data from a table: 我有这段代码试图从表中获取数据:

<?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;
?>

The result set is empty, and the table has data. 结果集为空,并且该表包含数据。 It does not return errors. 它不返回错误。 Please I need help. 请我帮忙。 Thanks to you all. 谢谢大家

<?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
}
?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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