JFactory Joomla Select
Joomla JFactory Select
我有这段代码试图从 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;
?>
结果集为空,table有数据。它不会 return 错误。
我需要帮助。谢谢大家。
<?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
}
?>
我有这段代码试图从 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;
?>
结果集为空,table有数据。它不会 return 错误。 我需要帮助。谢谢大家。
<?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
}
?>