darasion
V2EX  ›  问与答

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

  •  
  •   darasion · Jul 29, 2011 · 4821 views
    This topic created in 5471 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
        1
    reus  
       Jul 30, 2011
    http://www.yiiframework.com/doc/api/1.1/CActiveRecord#with-detail

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