簡體   English   中英

Joomla JFactory選擇

[英]Joomla JFactory Select

我有這段代碼試圖從表中獲取數據:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM