ActiveRecord里的attributes属性不管怎么样都是null。。。 [ 2.0 版本 ]
求救啊,自己怎么设置$this->属性名,甚至是设置$this->attributes=$array,打印出来都是空。。。oldattributes也是,我也设置了属性为safe了,不管是load或是直接赋值,attribute就一直是空,甚至刚赋完值再一打印还是空。。原谅我语无伦次了,真气疯了。。。
object(app\modules\admin\models\Article)[44]
public 'title' => string 'sdfs' (length=4)
public 'author' => string 'dfsd' (length=4)
public 'address' => string 'fgdf' (length=4)
public 'pubtime' => int 1451264799
public 'description' => string 'gdfgd' (length=5)
public 'abstract' => string 'dfgdf' (length=5)
public 'pic' => string '' (length=0)
public 'content' => string '<p>sdgdfgdfgdf</p>' (length=18)
public 'class' => string '2' (length=1)
public 'readnum' => null
public 'likes' => null
private '_attributes' (yii\db\BaseActiveRecord) =>
array (size=0)
empty
private '_oldAttributes' (yii\db\BaseActiveRecord) => null
private '_related' (yii\db\BaseActiveRecord) =>
array (size=0)
empty
private '_errors' (yii\base\Model) => null
求帮看一下,这里明明属性都是有值的,为什么attributes就一直为空呢?
['title','safe'] ,
['author','safe'] ,
['abstract','safe'] ,
['class','safe'] ,
分别设置safe
[['title','author','abstract','class','address','content','description','pic','id','pubtime','likes','readnum'],'safe'],
['title,author,abstract,class,address,content,description,pic,id,pubtime,likes,readnum','safe'],
一次设置全部safe,全都试过了,就是不行。。。。
共 2 个回答
枕边书 北京
注册时间:2015-12-15
最后登录:2016-01-12
在线时长:4小时21分
最后登录:2016-01-12
在线时长:4小时21分
- 粉丝0
- 金钱60
- 威望0
- 积分100