Magento Collection错误的结果

i want to get the catageory path of a category.

I got the parent and the child name and i'm doing the following:

$categorys = Mage::getResourceModel('catalog/category_collection')
    ->addAttributeToFilter('name', array("like" => $sCatName))
    ->getFirstItem()
    ->getChildrenCategories()
    ->addAttributeToFilter('name', array("like" => $sCatNameChild))
    ->addAttributeToSelect('*');

I checked the result with echo $categorys->getSelectSql();

It returns the correct Sql, run it over sql return 1 cat (correct one)

I count the collection and there are 8 selected categorys in there ( all subs of the parent)

Any idea why this is happening ?

Assuming $id is the id of your category. You may get path like this $category = Mage::getModel('catalog/category')->load($id); $path = explode('/', $category->getPath());

I have not tested this code but it must work