/** * * * @param $categories * @param $idCategory * @param $n * * @return bool Indicates whether the sub tree of categories has been successfully updated */ protected static function subTree(&$categories, $idCategory, &$n) { $left = $n++; if (isset($categories[(int) $idCategory]['subcategories'])) { foreach ($categories[(int) $idCategory]['subcategories'] as $idSubcategory) { Category::subTree($categories, (int) $idSubcategory, $n); } } $right = (int) $n++; return Db::getInstance()->update('category', array('nleft' => (int) $left, 'nright' => (int) $right), '`id_category` = ' . (int) $idCategory, 1); }