2013-07-08 43 views
0

找不到類'JTable'

我正在使用Joomla 2.5.11。我有一個php文件存儲在/ public_html/joomtest/components/com_jumi /下面粘貼的文件中。 我有一個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'); 

bu這再次沒有工作。請幫忙。

回答

2

您需要定義要使用的表文件的路徑。使用下面的代碼來包含特定的表格。例如:

JTable::addIncludePath(JPATH_SITE.DS.'components'.DS.'com_content'.DS.'tables'); 

然後打電話給你的表像下面:

$con_table = JTable::getInstance('Content', 'JTable', array()); 

希望這會工作。祝你好運。

+1

謝謝。有用。 – user2549928