JTable getInstance无效

时间:2014-09-10 08:11:26

标签: html css joomla

我正在尝试加载Table JoomShopping类别ID为3,但是当我执行EMPTY

时,它仅向我var_dump()提供了什么

从DB我可以看到有一个ID为3的类别

    $category_id = JRequest::getInt('category_id');
    $category = &JTable::getInstance('category', 'jshop');
    $category = $category->load(array('category_id'=>3));

     var_dump($category);exit;

请告诉我哪里出错了

1 个答案:

答案 0 :(得分:1)

您只需使用类别对象,就不需要将加载结果保存到任何变量。

尝试使用此代码 -

$category_id = JRequest::getInt('category_id');
$category = &JTable::getInstance('category', 'jshop');
$category->load(5);
print_r($category);exit;

//对于Joomla 3

$jinput = JFactory::getApplication()->input;
$category_id = $jinput->get('category_id', '', 'INT');    
$category = JTable::getInstance('category', 'jshop');
$category->load($category_id);
print_r($category);exit;