嗨,大家好,这可能是一个基本的但我是新手到PHP。 .so请不要...... 我有一个带有代码
的类api_category class API_CATEGORY extends API
{
// {{{ Class variables
public $fields = array (
'categoryid',
'catname',
'catdesc',
'catparentid',
'catviews',
'catsort',
'catpagetitle',
'catmetakeywords',
'catmetadesc',
'catsearchkeywords',
'catlayoutfile',
'catparentlist',
'catimagefile',
'cataltcategoriescache',
'cat_enable_optimizer',
);
protected $defaultvalues = array(
'cataltcategoriescache' => ''
);
public $categoryid = 0;
public $catname = '';
public $catdesc = '';
public $catparentid = 0;
public $catsort = 0;
public $catviews = 0;
public $catpagetitle = '';
public $catmetakeywords = '';
public $catmetadesc = '';
public $catsearchkeywords = '';
public $catlayoutfile = '';
public $catparentlist = '';
public $catimagefile = '';
public $cataltcategoriescache = '';
public $cat_enable_optimizer = '';
现在这也有一个使用这些变量的函数create。
我想调用此函数,因此请使用myfile.php中的以下代码
$c = new API_CATEGORY();
$c->catname="Test";
$c->catparentid=0;
$newid = $c->create();
但它表示未定义的索引catname 和未定义的索引capparentid。
我该如何解决这个问题?
有关详细信息,请参阅我希望调用的函数
public function create($updateCache = true)
{
$_POST['catparentlist'] = '';
$_POST['catviews'] = 0;
if (!$this->CategoryExists($_POST['catparentid'], $_POST['catname'])) {
$CatId = parent::create();
// If the save was successful
if($CatId) {
if ($updateCache) {
// adjust the nested set data for the new category
$nested = new ISC_NESTEDSET_CATEGORIES();
$nested->adjustInsertedNode($CatId, (int)$_POST['catparentid']);
// If the category doesn't have a parent, rebuild the root categories cache
if($_POST['catparentid'] == 0) {
$GLOBALS['ISC_CLASS_DATA_STORE']->UpdateRootCategories();
}
// Rebuild the group pricing caches
$GLOBALS['ISC_CLASS_DATA_STORE']->UpdateCustomerGroupsCategoryDiscounts();
}
// Also save our search record
$this->saveSearch($CatId);
// Save the words to the category_words table for search spelling suggestions
Store_SearchSuggestion::manageSuggestedWordDatabase("category", $CatId, $_POST["catname"]);
}
return $CatId;
} else {
$this->error = sprintf(GetLang('apiCatAlreadyExists'), $_POST['catname']);
return false;
}
}
因此,我希望catname
和catparentid
成为我想要的人:/ /