i'm creating category and items from api. her is function in add new cat
function addNewCat($mainCat, $lang, $aliasCat, $titleCat) {
// Set the extension. For content categories, use 'com_content'
$extension = 'com_content';
// Set the title for the category
$title = $titleCat;
// Type the description, this is also the 'body'. HTML allowed here.
$desc = '';
// Set the parent category. 1 is the root item.
$parent_id = $mainCat;
// JTableCategory is autoloaded in J! 3.0, so...
if (version_compare(JVERSION, '3.0', 'lt'))
{
JTable::addIncludePath(JPATH_PLATFORM . 'joomla/database/table');
}
// Initialize a new category
$category = JTable::getInstance('Category');
$category->extension = $extension;
$category->title = $title;
$category->alias=$aliasCat;
$category->description = $desc;
$category->published = 1;
$category->access = 1;
$category->params = '{"target":"","image":""}';
$category->metadata = '{"page_title":"","author":"","robots":""}';
$category->language = $lang;
// Set the location in the tree
$category->setLocation($parent_id, 'last-child');
// Check to make sure our data is valid
if (!$category->check())
{
JError::raiseNotice(500, $category->getError());
return false;
}
// Now store the category
if (!$category->store(true))
{
JError::raiseNotice(500, $category->getError());
return false;
}
// Build the path for our category
$status = $category->rebuildPath($category->id);
if (!$status) {
return $category->id;
} else {
return $status;
}
}
1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') ORDER BY level ASC' at line 1 SQL=SELECT id, params FROM #__categories WHERE id IN () ORDER BY level ASC