symfony 1.4:重新声明的 getter 使原则:数据加载任务静默失败
这是我的架构的一部分:
sfGuardUser:
actAs: [Timestampable]
columns:
email_address:
type: string(255)
notnull: true
unique: true
algorithm:
type: string(128)
default: sha1
notnull: true
salt: string(128)
password: string(128)
balance:
type: decimal(14)
scale: 4
default: 0
guarantee:
type: decimal(14)
scale: 4
default: 0
is_active:
type: boolean
default: 1
is_super_admin:
type: boolean
default: false
last_login:
type: timestamp
这是固定数据:
sfGuardUser:
User_admin_1:
email_address: [email protected]
password: admin
balance: 10000
is_super_admin: true
这是使其失败的 getter
class sfGuardUser extends PluginsfGuardUser
{
...
public function getBalance()
{
return (parent::getBalance() - $this->getGuarantee());
}
}
如果我删除 parent::getBalance()
一切正常。它有什么问题吗?
Here is my part of my schema:
sfGuardUser:
actAs: [Timestampable]
columns:
email_address:
type: string(255)
notnull: true
unique: true
algorithm:
type: string(128)
default: sha1
notnull: true
salt: string(128)
password: string(128)
balance:
type: decimal(14)
scale: 4
default: 0
guarantee:
type: decimal(14)
scale: 4
default: 0
is_active:
type: boolean
default: 1
is_super_admin:
type: boolean
default: false
last_login:
type: timestamp
Here is fixture data:
sfGuardUser:
User_admin_1:
email_address: [email protected]
password: admin
balance: 10000
is_super_admin: true
Here is getter which make it fail
class sfGuardUser extends PluginsfGuardUser
{
...
public function getBalance()
{
return (parent::getBalance() - $this->getGuarantee());
}
}
If I remove parent::getBalance()
everything works fine. What's trouble with it ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最好调用
$this->get('balance')
或$this->_get('balance')
从 Doctrine 获取记录。这些函数检索学说模型中的值。It's better to call
$this->get('balance')
or$this->_get('balance')
to get a record from Doctrine. These functions retrieve the value in the doctrine model.