简体   繁体   English

找不到“JTable”类

[英]Class 'JTable' not found

I am using Joomla 2.5.11 . 我正在使用Joomla 2.5.11。 I have a php file stored in the /public_html/joomtest/components/com_jumi/files which is pasted below. 我有一个存储在/ public_html / joomtest / components / com_jumi /文件中的php文件,粘贴在下面。 I have a PHP form which is stored in the same location ie /public_html/joomtest/components/com_jumi/files. 我有一个PHP表单,存储在相同的位置,即/ public_html / joomtest / components / com_jumi / files。

I want the PHP form to call the PHP script so that an article is created in Joomla. 我希望PHP表单调用PHP脚本,以便在Joomla中创建一篇文章。 But whenever the PHP script is called, I receive the below error 但是每当调用PHP脚本时,我都会收到以下错误

Fatal error: Class 'JTable' not found

and the line on which Joomla throws error is 并且Joomla抛出错误的行是

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

PHP script 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>

I tried putting in 我试过投入

require_once('/libraries/joomla/database/table.php');

but this again didnt work. 但这再次没有奏效。 Please help. 请帮忙。

You need to define path of table file you want to use. 您需要定义要使用的表文件的路径。 Use the following code for include the specific table. 使用以下代码包含特定表。 For example: 例如:

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

And then call your table like below: 然后像下面那样打电话给你的桌子:

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

Hope this will work. 希望这会奏效。 Good Luck. 祝好运。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM