我喜欢阅读来自 Joomla 2.5 的 id 文章。因为我不在框架内,所以我必须先包含它。我还发现了一些如何通过 id 获取文章的示例,但它曾经失败过......这是我正在尝试的示例:
define( '_JEXEC', 1 );
define( '_VALID_MOS', 1 );
define( 'JPATH_BASE', realpath(dirname(__FILE__)));
define( 'DS', DIRECTORY_SEPARATOR );
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
echo JPATH_BASE .DS.'includes'.DS.'framework.php';
$mainframe =& JFactory::getApplication('site');
$mainframe->initialise();
echo $mainframe->getCfg('sitename');
$articleId = JRequest::getInt('Itemid');
$db =& JFactory::getDBO();
$sql = "SELECT fulltext FROM #__content WHERE id = 260"; //.intval($articleId);
$db->setQuery($sql);
$fullArticle = $db->loadResult();
文章 ID 260 可用,但它曾经返回 null ...
当我跟踪它时, loadResult() 中的 $cursor 是每个空值:
public function loadResult()
{
// Initialise variables.
$ret = null;
// Execute the query and get the result set cursor.
if (!($cursor = $this->execute()))
{
return null;
}
...
有人可以帮忙吗?
谢谢安德烈