2012-03-28 89 views
-1

我更改了我的評論模塊中的生成器,以便默認列出的結果不同。我只加了「table_method」值:Symfony - 管理生成器過濾器

list: 
    table_method: commentParent 

然後,我添加了commentParent功能是這樣的:

public function commentParent(Doctrine_Query $q) { 
    $rootAlias = $q->getRootAlias(); 

    $q->where($rootAlias . '.parent_id is null or ' . $rootAlias . '.parent_id = 0'); 

    return $q; 
} 

列出的結果是正確的,但使用這種方法,現在過濾器將不能正常工作。在開發模式下,我可以看到它們在用戶變量中正確設置,但它們沒有效果。

我可能會錯過什麼?

回答

0

使用addWhere而不是where,因爲它(where)刪除所有以前添加的where子句。