darasion
V2EX  ›  问与答

Yii框架问题:怎样知道AR对象的某个属性是with() 中指定的关联?

  •  
  •   darasion · Jul 29, 2011 · 5021 views
    This topic created in 5608 days ago, the information mentioned may be changed or developed.
    hi,

    我的问题是这样的:

    $xxx = Xxx::model()->with('column')->find ...


    我怎么在$xxx这个对象中知道 $xxx 已经载入了column这个关联,而不是使用lazyload载入的?

    我是想重写 $xxx->getAttributes() 或者定义另一个方法,让它可以返回with中指定关联的属性。

    项目中的版本是:Yii v1.0.7

    谢谢.
    1 replies  •  1970-01-01 08:00:00 +08:00
    reus
    reus
    Jul 30, 2011
    1
    http://www.yiiframework.com/doc/api/1.1/CActiveRecord#with-detail

    看看这个方法的源码,看有没有把参数记录到什么地方呗
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   894 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 20:54 · PVG 04:54 · LAX 12:54 · JFK 15:54
    ♥ Do have faith in what you're doing.