symfony 外键一对多
我有两个表 A (Utenti) e B (Dispositivi); B 上有一个指向 A 的外键(一个 Utente-> 许多 Dispositivi)。我使用 symfony 管理生成器。我可以为每个 Utente 生成一个链接,在 Dispositivi 视图中列出所有相关的 Dispositivi 吗?这可能吗?
架构.yml
Dispositivi:
connection: doctrine
tableName: dispositivi
columns:
id_dispositivo:
type: integer(4)
fixed: false
unsigned: false
primary: true
autoincrement: true
device_id:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
tipo:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
utente_fk:
type: integer(4)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
relations:
Utenti:
local: utente_fk
foreign: id_utente
type: one
Utenti:
connection: doctrine
tableName: utenti
columns:
id_utente:
type: integer(4)
fixed: false
unsigned: false
primary: true
autoincrement: true
username:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
password:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
tipo:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
relations:
Dispositivi:
local: id_utente
foreign: utente_fk
type: many
Servizi:
local: id_utente
foreign: utente_fk
type: many
I have two tables A (Utenti) e B (Dispositivi); on B there is a foreign key to A (one Utente->many Dispositivi). I used symfony admin generator. Can I generate a link for each Utente that list me all the related Dispositivi in the Dispositivi view. Is it possible this?
schema.yml
Dispositivi:
connection: doctrine
tableName: dispositivi
columns:
id_dispositivo:
type: integer(4)
fixed: false
unsigned: false
primary: true
autoincrement: true
device_id:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
tipo:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
utente_fk:
type: integer(4)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
relations:
Utenti:
local: utente_fk
foreign: id_utente
type: one
Utenti:
connection: doctrine
tableName: utenti
columns:
id_utente:
type: integer(4)
fixed: false
unsigned: false
primary: true
autoincrement: true
username:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
password:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
tipo:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
relations:
Dispositivi:
local: id_utente
foreign: utente_fk
type: many
Servizi:
local: id_utente
foreign: utente_fk
type: many
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
以下是学说代码的一个很好的参考:
http://redotheweb .com/2008/07/08/comparing-propel-doctrine-and-sfpropelfinder/
(特别是如果使用 fou 来推动的话。)
首先,在generator.yml 文件中添加一个部分。
然后做这样的事情:
Here is a good reference for doctrine code:
http://redotheweb.com/2008/07/08/comparing-propel-doctrine-and-sfpropelfinder/
(especially if fou are used to propel.)
First, add a partial in the generator.yml file.
Then do something like this: