duankanyi6539 2010-07-28 22:06
浏览 20
已采纳

在Doctrine中编写模型方法

I'd like to encapsulate functionality specific to certain models by including methods in the model class definitions. So, for example:

abstract class BaseUser extends DoctrineRecord {    

    public function setTableDefinition(){  
       //etc.  
    }  

    public function setUp(){  
       //etc.  
    } 

    public function getName(){  
       return $this->name  
    }
}

$this->name throws an error, as does $name. Is it possible to access the model properties from here?

  • 写回答

2条回答 默认 最新

  • doujia4041 2010-07-28 23:23
    关注

    Properties can be accessed using $this->propertyName as anyone would expect. My problem was that getProperty (getName in my example) is a function that the Doctrine framework automatically creates, creating a conflict when I tried to create my own. I changed the name to whatIsName() and everything worked.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 2024-五一综合模拟赛
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭