创建3级子查询Propel

Hi guys I would like to ask if anyone of you know how to create a select statement in propel using a 3 level subquery... Initially I have this query and it works fine but I want it to be more like propel type... can anyone help me with this?

Here's my query

select c.*, count(d.id) as like_count from (
    select a.*, count(b.id) as points_count
    from (
        select * 
        from reviews 
        where user_id ='3') a 
    left join points as b on (a.id = b.type_id) 
    where b.type='review'
    group by a.id 
    order by a.created desc) c left join `like` d on (c.id = d.type_id) group by c.id

Here's what I have so far but just from the 2 level subquery the output query is not right

$review = ReviewsQuery::create()->filterByUserId($user_id);
$points = PointsQuery::create('b')
        ->withColumn("COUNT(b.Id)", 'points_count')
        ->addSelectQuery($review, 'a', true)
        ->toString(); // This is just to check what will be the query output

Can anyone help me with this please

I've not done what you need to do before and always presumed when I would need to run complex queries such as yours, I would just get Propel to run a custom query.

This might not be the appropriate way to do it, but thought I'd point it out just in case it wasn't something you'd seen. There's a description on how to do it on this page about half way down: http://propelorm.org/documentation/03-basic-crud.html

You can anidate subqueries by:

__LEVEL 1

$c1 = new ReviewsQuery();//First query
$c1->addSelfSelectColumns();//implement all columns
$c1->filterByUserId(3);//the where clause --where user_id ='3'--

__Level 2

$s1 = new ReviewsQuery();//Second Level 
$s1->addSelectQuery($c1,"a"); // Implements first query
$s1->addAlias("b",PointsTableMap::COL_TYPE_ID); //prepare Join
$s1->addJoin("a.Id",PointsTableMap::alias("b",PointsTableMap::COL_TYPE_ID))//Add the join
$s1->where(PointsTableMap::alias("b",PointsTableMap::COL_TYPE)."=?",'review')//filter by -- where b.type='review' --

(... group by...select...etc ...)

__LEVEL 3

$c3 = new ReviewsQuery();//The high level Query
$c3->addSelectQuery($s1,"c");//adding a subquery as "c" 
$c3->addJoin... //continue as a normal Query Object

Be care whith namespaces... there are some bugs working whith that in Propel2