douying7289 2011-08-08 07:22
浏览 37
已采纳

symfony 1.4:redeclared getter make doctrine:数据加载任务无声地失败

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:  admin@company.com
    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 ?

  • 写回答

1条回答 默认 最新

  • doujiao3998 2011-08-08 09:28
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作
  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?
  • ¥30 我的代码按理说完成了模型的搭建、训练、验证测试等工作(标签-网络|关键词-变化检测)
  • ¥50 mac mini外接显示器 画质字体模糊
  • ¥15 TLS1.2协议通信解密
  • ¥40 图书信息管理系统程序编写
  • ¥20 Qcustomplot缩小曲线形状问题
  • ¥15 企业资源规划ERP沙盘模拟