$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.'],
];
}
id 在数据库里有没有设置为自动递增