Doctrine 中一个表可以有多个 slugs 吗?
Doctrine 中一张桌子上可以有多个 slugs 吗?
我在我的 yaml 文件中尝试了这个:
Article:
tableName: tst_article
actAs:
Sluggable:
unique: true
fields: [title]
canUpdate: true
Sluggable:
unique: true
fields: [text]
name: secondSlug
columns:
id:
type: integer(8)
primary: true
autoincrement: true
category_id:
type: integer(8)
title:
type: text(255)
text:
type: clob
但是在生成 sql 后,只生成了第二个Slug...
Is it possible to have multiple slugs on one table in Doctrine?
I tried this in my yaml-file:
Article:
tableName: tst_article
actAs:
Sluggable:
unique: true
fields: [title]
canUpdate: true
Sluggable:
unique: true
fields: [text]
name: secondSlug
columns:
id:
type: integer(8)
primary: true
autoincrement: true
category_id:
type: integer(8)
title:
type: text(255)
text:
type: clob
But after generating the sql only the secondSlug was generated...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是可能的。在表定义中写入:
问题出在 YAML 本身。你有这样的东西:
可能会被翻译成:
正如你所看到的,有
keyB
的定义,然后keyB
被新值覆盖。因此,在 YAML 文件中,第二个定义会覆盖第一个定义。怎么解决呢?我不知道,但我会做一些研究。现在您被迫用纯 PHP 声明您的模型。
It is possible. In your table definition write:
The problem is in YAML itself. You have something like this:
What might be translated into:
So as you see there is definition of
keyB
and thenkeyB
is overwritten with new value. So in your YAML file second definition overrides the first one.How to solve that? I don't know, but I'll do some researches. Right now you're forced to declare your models in pure PHP.
尽管不建议更改库,但有时这是一种必要的罪恶。一个非常小的更改允许您在 YAML 中声明
Sluggable_1
、Sluggable_2
等。Although changing libraries is not recommended, sometimes it's a necessary evil. A very small change allows you to declare
Sluggable_1
,Sluggable_2
, etc. in your YAML.