我是Symfony和Doctrine的新手,正在編寫一個Web應用程序。我將sfDoctrineGuardPlugin添加到我的項目中。當我打開了插件的schema.yml文件,我看到這一點:sfGuardUser表是否有主鍵?
sfGuardUser:
actAs: [Timestampable]
columns:
first_name: string(255)
last_name: string(255)
email_address:
type: string(255)
notnull: true
unique: true
username:
type: string(128)
notnull: true
unique: true
algorithm:
type: string(128)
default: sha1
notnull: true
salt: string(128)
password: string(128)
is_guest:
type: boolean
default: 0
is_active:
type: boolean
default: 1
is_super_admin:
type: boolean
default: false
last_login:
type: timestamp
indexes:
is_active_idx:
fields: [is_active]
relations:
Groups:
class: sfGuardGroup
local: user_id
foreign: group_id
refClass: sfGuardUserGroup
foreignAlias: Users
Permissions:
class: sfGuardPermission
local: user_id
foreign: permission_id
refClass: sfGuardUserPermission
foreignAlias: Users
請問這個模式產生了主鍵的表(如果是這樣,我怎麼訪問它)?我在網上查看,大部分涵蓋sfGuardUser架構的頁面都顯示一個id列,它是主鍵。我錯過了什麼?謝謝。
感謝您的回覆。顯式定義sfGuardUser模式中的id列是否是一種好的做法?如果是這樣,你會如何推薦定義它? – 2011-05-14 16:47:43
@ The Traveling Coder:我個人喜歡定義架構中的所有列,因爲我發現它更清晰,我不喜歡Doctrine在幕後爲我做事。但是,對於sfGuardUser,我可能不會碰它,因爲插件本身的更新可能會覆蓋架構 - 就像剛剛發佈的那樣。 – Tom 2011-05-14 18:34:06
儘管我很喜歡Symfony和Doctrine,但在學習新框架時,我發現automagic是一個障礙。您能澄清一下最後一個細節:因爲您建議不改變sfGuardUser架構,那麼如果我想存儲更多用戶數據,我需要創建一個配置文件模型並將其與sfGuardUser關聯,對嗎?示例:[http://symfony.com/blog/call-the-expert-customizing-sfdoctrineguardplugin](http://symfony.com/blog/call-the-expert-customizing-sfdoctrineguardplugin) – 2011-05-14 21:07:43