Example #1
0
 public static function get($id, $language_id = null, $key = null)
 {
     global $lC_Database, $lC_Language;
     if (empty($language_id)) {
         $language_id = $lC_Language->getID();
     }
     $lC_CategoryTree = new lC_CategoryTree_Admin();
     $Qcategories = $lC_Database->query('select * from :table_categories where categories_id = :categories_id');
     $Qcategories->bindTable(':table_categories', TABLE_CATEGORIES);
     $Qcategories->bindInt(':categories_id', $id);
     $Qcategories->execute();
     $data = $Qcategories->toArray();
     $data['childs_count'] = sizeof($lC_CategoryTree->getChildren($Qcategories->valueInt('categories_id'), $dummy = array()));
     $data['products_count'] = $lC_CategoryTree->getNumberOfProducts($Qcategories->valueInt('categories_id'));
     $Qdescription = $lC_Database->query('select * from :table_categories_description where categories_id = :categories_id');
     $Qdescription->bindTable(':table_categories_description', TABLE_CATEGORIES_DESCRIPTION);
     $Qdescription->bindInt(':categories_id', $id);
     $Qdescription->execute();
     while ($Qdescription->next()) {
         $data[$Qdescription->valueInt('language_id')]['categories_name'] = $Qdescription->value('categories_name');
         $data[$Qdescription->valueInt('language_id')]['categories_menu_name'] = $Qdescription->value('categories_menu_name');
         $data[$Qdescription->valueInt('language_id')]['categories_blurb'] = $Qdescription->value('categories_blurb');
         $data[$Qdescription->valueInt('language_id')]['categories_description'] = $Qdescription->value('categories_description');
         $data[$Qdescription->valueInt('language_id')]['categories_tags'] = $Qdescription->value('categories_tags');
     }
     $Qpermalink = $lC_Database->query('select language_id, permalink from :table_permalinks where item_id = :item_id and type = 1');
     $Qpermalink->bindTable(':table_permalinks', TABLE_PERMALINKS);
     $Qpermalink->bindInt(':item_id', $id);
     $Qpermalink->execute();
     while ($Qpermalink->next()) {
         $data[$Qpermalink->valueInt('language_id')]['permalink'] = $Qpermalink->value('permalink');
     }
     $Qcategories->freeResult();
     $Qdescription->freeResult();
     $Qpermalink->freeResult();
     if (!empty($key) && isset($data[$key])) {
         $data = $data[$key];
     }
     return $data;
 }