save attributes['id']方法获取不到id号 [ 2.0 版本 ]
$userOpenId = new UserOpenId([
'openid'=>(string)$openId,
'opentype'=>$openType,
'userName'=>$userName
]);
if($userOpenId->save()){
$id = $userOpenId->attributes['id'];var_dump($id);exit;
}
public function rules()
{
return [
[['id'], 'integer'],
[['userId'], 'integer'],
[['opentype'], 'string', 'max' => 60],
[['userName'], 'string', 'max' => 60],
[['openhash'], 'string', 'max' => 32],
[['openid'], 'string', 'max' => 255],
[['opentype', 'openhash'], 'unique', 'targetAttribute' => ['opentype', 'openhash'], 'message' => 'The combination of Opentype and Openhash has already been taken.'],
];
}
最佳答案
其他 0 个回答
没有找到数据。
kevin19a
注册时间:2016-12-22
最后登录:2017-11-20
在线时长:5小时12分
最后登录:2017-11-20
在线时长:5小时12分
- 粉丝0
- 金钱130
- 威望0
- 积分180