0

我尝试在我的数据库中获取用户的 Facebook 信息。我在 UserIdentity 中来控制用户的身份验证,我创建了这个方法。

<?php
public function insertFbUser()
{
    $user = new User();
        $user->fbId = $this->username['id'];
        $user->username = $this->username['username'];
        $user->email = $this->username['email'];
        $user->password = $this->password;

    $profile = new Profile();
        $profile->first_name = $this->username['first_name'];
        $profile->last_name = $this->username['last_name'];
        $profile->birthday = strtotime($this->username['birthday']);
        $profile->sex = $this->username['gender'];
        $profile->fb_updated_time = strtotime($this->username['updated_time']);
        $profile->fb_verified = $this->username['verified'];
        $profile->fb_educationJson = json_encode($this->username['education']);
        $profile->fb_workJson = json_encode($this->username['work']);

    var_dump($user->save());
    var_dump($profile->save());
}

var_dump() 给我看这个

boolean true
boolean false

这两个模型都是使用 GII 模块创建的。我尝试一次只放置一个 prile 属性,但它也不起作用......

有我的数据库: http: //pastebin.com/u5CNKj9M

谢谢您的帮助!

4

1 回答 1

4

print_r($profile->getErrors());

(更新)保存后获取用户ID:

$user->save();
$user_id = $user->id
于 2012-09-22T21:15:50.523 回答