我的应用程序symfony管理视频和视频评论,因此我有两个捆绑包videoBundle和commentBundle。
在我的应用程序symfony中,我使用多个数据库连接,每个客户都连接到他的数据库。
这是我的Video.orm.yml
VideoBundle\Entity\Video:
type: entity
table: null
repositoryClass: VideoBundle\Repository\VideoRepository
id:
id:
type: integer
id: true
generator:
strategy: AUTO
fields:
fileTitle:
type: string
length: 255
column: file_title
nullable: true
title:
type: string
length: 255
...
oneToMany:
comments:
targetEntity: CommentBundle\Entity\Comment
mappedBy: video
cascade: ["persist","remove","merge"]
joinColumn:
onDelete: CASCADE
这是我的Comment.orm.yml
CommentBundle\Entity\Comment:
type: entity
table: null
repositoryClass: CommentBundle\Repository\CommentRepository
id:
id:
type: integer
id: true
generator:
strategy: AUTO
fields:
texte:
type: string
length: 255
manyToOne:
video:
targetEntity: VideoBundle\Entity\Video
cascade: ["persist"]
inversedBy: comments
joinColumn:
name: video_id
referencedColumnName: id
onDelete: "CASCADE"
options:
comment: Video Id
这是我的配置管理器:
doctrine:
dbal:
default_connection: "%doctrine.default_connection%"
connections:
default:
driver: pdo_mysql
host: "%connections.default.host%"
port: "%connections.default.port%"
dbname: "%connections.default.dbname%"
user: "%connections.default.user%"
password: "%connections.default.password%"
charset: UTF8
mapping_types:
enum: string
custumer1:
driver: pdo_mysql
host: "%connections.custumer1.host%"
port: "%connections.custumer1.port%"
dbname: "%connections.custumer1.dbname%"
user: "%connections.custumer1.user%"
password: "%connections.custumer1.password%"
charset: UTF8
mapping_types:
enum: string
custumer2:
driver: pdo_mysql
host: "%connections.custumer2.host%"
port: "%connections.custumer2.port%"
dbname: "%connections.custumer2.dbname%"
user: "%connections.custumer2.user%"
password: "%connections.custumer2.password%"
charset: UTF8
mapping_types:
enum: string
orm:
default_entity_manager: "%doctrine.default_orm%"
auto_generate_proxy_classes: "%kernel.debug%"
entity_managers:
default:
naming_strategy: doctrine.orm.naming_strategy.underscore
connection: default
dql:
numeric_functions:
time_diff: CoreBundle\DQL\TimeDiff
rand: CoreBundle\DQL\RandFunction
string_functions:
replace: CoreBundle\DQL\Replace
mappings:
VideoBundle: ~
CommentBundle: ~
FOSUser:
mapping: true
type: 'xml'
dir: "%kernel.root_dir%/../vendor/friendsofsymfony/user-bundle/Resources/config/doctrine-mapping/"
alias: 'FOSUser'
prefix: FOS\UserBundle\Model
is_bundle: false
custumer1:
naming_strategy: doctrine.orm.naming_strategy.underscore
connection: custumer1
dql:
numeric_functions:
time_diff: CoreBundle\DQL\TimeDiff
rand: CoreBundle\DQL\RandFunction
string_functions:
replace: CoreBundle\DQL\Replace
mappings:
VideoBundle: ~
CommentBundle: ~
FOSUser:
mapping: true
type: 'xml'
dir: "%kernel.root_dir%/../vendor/friendsofsymfony/user-bundle/Resources/config/doctrine-mapping/"
alias: 'FOSUser'
prefix: FOS\UserBundle\Model
is_bundle: false
custumer2:
naming_strategy: doctrine.orm.naming_strategy.underscore
connection: custumer2
dql:
numeric_functions:
time_diff: CoreBundle\DQL\TimeDiff
rand: CoreBundle\DQL\RandFunction
string_functions:
replace: CoreBundle\DQL\Replace
mappings:
VideoBundle: ~
CommentBundle: ~
FOSUser:
mapping: true
type: 'xml'
dir: "%kernel.root_dir%/../vendor/friendsofsymfony/user-bundle/Resources/config/doctrine-mapping/"
alias: 'FOSUser'
prefix: FOS\UserBundle\Model
is_bundle: false
我想为某些客户使用这种关系,并希望在某些客户中使用无评论的视频。
客户如何使用无评论的视频,没有捆绑的commentBundle。
我该怎么做?