我有两个实体之间有关联:
Labs\CatalogBundle\Entity\ProductExtraspecs:
type: entity
table: orders__regmat__extraspecs
fields:
regmatid:
id: true
type: integer
scale: 11
specid:
id: true
type: integer
scale: 11
attrib:
type: string
length: 20
value:
type: string
length: 200
lifecycleCallbacks: { }
manyToOne:
specs:
targetEntity: Specs
inversedBy: specs
joinColumn:
name: specid
referencedColumnName: specid
和
Labs\CatalogBundle\Entity\Specs:
type: entity
table: orders__regmat__extraspecs__specs
fields:
specid:
id: true
type: integer
unsigned: false
nullable: false
generator:
strategy: IDENTITY
desc:
type: string
length: 200
fixed: false
nullable: false
cat:
type: integer
unsigned: false
nullable: false
type:
type: integer
unsigned: false
nullable: false
lifecycleCallbacks: { }
oneToMany:
specs:
targetEntity: ProductExtraspecs
mappedBy: specs
所以在控制器中我想用 and 获取所有行regmatid = 8
并尝试了cat = 0
这个:
$selRepository = $this -> getDoctrine() ->getEntityManager()->getRepository('LabsCatalogBundle:ProductExtraspecs');
$query = $selRepository->createQueryBuilder('sel')
//->select('count(c.protid) as cnt')
->where("sel.cat = '0' AND sel.regmatid = $id")
//->setParameter('price', '19.99')
->getQuery();
$selected = $query->getResult();
但是得到一个错误说:
[语义错误] line 0, col 74 near 'cat = '0' AND': Error: Class Labs\CatalogBundle\Entity\ProductExtraspecs 没有名为 cat 的字段或关联
如何访问关联实体的字段?你能帮我吗?
先感谢您 :)