0
我有两个Entities,Plan和PricingTier。该计划映射到我的计划表并具有名为pricing_tier_id的列。这通过其id列映射到PricingTiers表。实体具有从Plan到PricingTier的manyToOne关联,以及从PricingTier到Plan的OneToMany关联。这些都是下面:选择关联关键字的所有记录
计划实体
etrak\OnlineOrderProcessingBundle\Entity\Plan:
type: entity
table: plans
id:
id:
type: integer
generator: { strategy: AUTO }
fields:
name:
type: string
length: 255
nullable: true
description:
type: text
nullable: true
termsConditions:
column: terms_conditions
type: text
nullable: true
active:
type: boolean
nullable: true
amount:
type: decimal
nullable: true
scale: 2
precision: 5
affinity:
type: boolean
nullable: true
deactivationFee:
column: deactivation_fee
type: decimal
scale: 2
precision: 5
nullable: true
gracePeriodDays:
column: grace_period_days
type: integer
nullable: true
recurringInMonths:
column: recurring_in_months
type: integer
nullable: true
activeStartDate:
column: active_start_date
type: date
activeEndDate:
column: active_end_date
type: date
lifecycleCallbacks:
prePersist: [ prePersist ]
manyToOne:
pricingTier:
targetEntity: PricingTier
inversedBy: plans
joinColumn:
name: pricing_tier_id
referencedColumnName: id
PricingTier实体
etrak\OnlineOrderProcessingBundle\Entity\PricingTier:
type: entity
table: pricing_tiers
id:
id:
type: integer
generator: { strategy: AUTO }
fields:
name:
type: string
length: 50
description:
type: string
length: 100
nullable: true
minimumDevices:
column: minimum_devices
type: integer
isAffinity:
column: is_affinity
type: boolean
keyname:
type: string
length: 55
createdBy:
column: created_by
type: string
length: 20
createdOn:
column: created_on
type: datetime
updatedOn:
column: updated_on
type: datetime
nullable: true
lifecycleCallbacks:
prePersist: [ onPrePersist ]
preUpdate: [ onPreUpdate ]
oneToMany:
plans:
targetEntity: Plan
mappedBy: pricingTier
oneToOne:
product:
targetEntity: Product
joinColumn:
name: product_id
referencedColumnName: id
什么,我需要做的是一样的东西:SELECT * FROM WHERE计划= pricing_tier_id 2
如果可能,我想远离SQL/DQL。教义确实有内置的方法来做到这一点?请注意,我在Symfony 2.1中使用Doctrine作为一个包。
这工作得很好!谢谢!一旦我打开PricingTier.php实体文件,我看到里面有一个getPlans()方法:) – Ronny