[英]Class 'JTable' not found
我正在使用Joomla 2.5.11。 我有一個存儲在/ public_html / joomtest / components / com_jumi /文件中的php文件,粘貼在下面。 我有一個PHP表單,存儲在相同的位置,即/ public_html / joomtest / components / com_jumi / files。
我希望PHP表單調用PHP腳本,以便在Joomla中創建一篇文章。 但是每當調用PHP腳本時,我都會收到以下錯誤
Fatal error: Class 'JTable' not found
並且Joomla拋出錯誤的行是
$table = JTable::getInstance('Content', 'JTable', array());
PHP腳本
<?php
$table = JTable::getInstance('Content', 'JTable', array());
$data = array(
'catid' => 8,
'title' => 'SOME TITLE',
'introtext' => 'SOME TEXT',
'fulltext' => 'SOME TEXT',
'state' => 0,
);
if (!$table->bind($data))
{
$this->setError($table->getError());
return false;
}
if (!$table->check())
{
$this->setError($table->getError());
return false;
}
if (!$table->store())
{
$this->setError($table->getError());
return false;
}
?>
</body>
</html>
我試過投入
require_once('/libraries/joomla/database/table.php');
但這再次沒有奏效。 請幫忙。
您需要定義要使用的表文件的路徑。 使用以下代碼包含特定表。 例如:
JTable::addIncludePath(JPATH_SITE.DS.'components'.DS.'com_content'.DS.'tables');
然后像下面那樣打電話給你的桌子:
$con_table = JTable::getInstance('Content', 'JTable', array());
希望這會奏效。 祝好運。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.