src/Money/DataMapper/Mapper/Money/CategoryMapper.php
public function findAllByAccountId($accountId, $categoryId = 0)
    {
        $accountId  = (int) $accountId;
        $categoryId = (int) $categoryId;

        if ($categoryId > 0) {
            $this->addWhere('category_id', (int) $categoryId, '!=');
        }

        $this->addWhere('account_id', $accountId);
        $this->addOrder('category_parent_id');
        $this->addOrder('category_name');
        $list = $this->select();

        $categories = array();
        foreach ($list as $category) {
            if ($category->getParentId() === 0) {
                $categories[$category->getId()] = $category;
            } elseif (isset($categories[$category->getParentId()])) {
                $categories[$category->getParentId()]->addChild($category);
            }
        }

        return $categories;
    }
public function findAllByAccountId($accountId, $categoryId = 0)
    {
        $accountId  = (int) $accountId;
        $categoryId = (int) $categoryId;

        if ($categoryId > 0) {
            $this->addWhere('category_id', (int) $categoryId, '!=');
        }

        $this->addWhere('account_id', $accountId);
        $this->addOrder('category_parent_id');
        $this->addOrder('category_name');
        $list = $this->select();

        $categories = array();
        foreach ($list as $category) {
            if ($category->getParentId() === 0) {
                $categories[$category->getId()] = $category;
            } elseif (isset($categories[$category->getParentId()])) {
                $categories[$category->getParentId()]->addChild($category);
            }
        }

        return $categories;
    }
Get list of categories by account (category / subcategories)

@param  int $accountId
@param  int $categoryId
@return Category[]