我有这个代码试图从表中获取数据:
<?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;
?>
结果集为空,表中有数据。它不会返回错误。 我需要帮助。谢谢大家。
答案 0 :(得分:0)
<?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
}
?>