Newbie question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
obiw1
Forum Newbie
Posts: 1
Joined: Tue May 05, 2009 2:37 pm

Newbie question

Post by obiw1 »

I'm a real newbie, i have no PHP experience. I did work whit stuff like WordPress but never in the code.
I've a open source webshop where i like to expand the categories and sub categories. I think i found the place where the categories are generated. I understand a bit of the code but not enough

Code: Select all

<?php
class ModelCatalogCategory extends Model {
    public function getCategory($category_id) {
        $query = $this->db->query("SELECT DISTINCT * FROM category c LEFT JOIN category_description cd ON (c.category_id = cd.category_id) WHERE c.category_id = '" . (int)$category_id . "' AND cd.language_id = '" . (int)$this->language->getId() . "'");
        
        return $query->row;
    }
    
    public function getCategories($parent_id = 0) {
        $query = $this->db->query("SELECT * FROM category c LEFT JOIN category_description cd ON (c.category_id = cd.category_id) WHERE c.parent_id = '" . (int)$parent_id . "' AND cd.language_id = '" . (int)$this->language->getId() . "' ORDER BY c.sort_order");
 
        return $query->rows;
    }
                
    public function getTotalCategoriesByCategoryId($parent_id = 0) {
        $query = $this->db->query("SELECT COUNT(*) AS total FROM category WHERE parent_id = '" . (int)$parent_id . "'");
        
        return $query->row['total'];
    }
}
?>
Hope someone can help me
david64
Forum Commoner
Posts: 53
Joined: Sat May 02, 2009 8:12 am
Location: Wales

Re: Newbie question

Post by david64 »

Yes. It looks like you've got the right file, but what do you want to do?
Post Reply