我如何完成这个 andWhere Doctrine 查询?

How do I complete this andWhere Doctrine query?

我假设使用 Doctrine 很容易做到这一点,但我不知道如何去做。我确定我缺少一些基本的东西。

    Doctrine_Query::create()
                    ->from('Product p')
                    ->leftJoin('p.Category c' )
                    ->leftJoin('c.Image i')
                    ->where('p.name LIKE ?', '%'.$search.'%'),

有效,但我正在尝试 select 类别并尝试了这个,但它没有用错误 "Unknown column parent_id"

    Doctrine_Query::create()
                    ->from('Product p')
                    ->leftJoin('p.Category c' )
                    ->leftJoin('c.Image i')
                    ->where('p.name LIKE ?', '%'.$search.'%')
                    ->andWhere('c.parent_id NOT LIKE ?', '1'),

如何更改此 Doctrine 查询以包含 andWhere 语句?

这有点像猜测,因为我不知道您的架构。 DQL 查询使用属性而不是数据库列名。我怀疑该类别有一个名为 parent?

的 属性

所以像这样:

Doctrine_Query::create()
    ->select('p,c,i')  // Eager load
    ->from('Product p')
    ->leftJoin('p.Category c' )
    ->leftJoin('c.Image i')
    ->leftJoin('c.Parent parentCategory') // Join the parent entity
    ->where('p.name LIKE ?', '%'.$search.'%')
    ->andWhere('parentCategory.id NOT LIKE ?', '1'),