public function save($isNewUser = false) { //create a new database object. $db = new DB(); //if the user is already registered and we're //just updating their info. if (!$isNewUser) { //set the data array $data = array("name" => "'{$this->name}'", "linkedin_id" => "'{$this->linkedin_id}'", "pic_url" => "'{$this->pic_url}'", "company_id" => "{$this->company_id}", "profile_url" => "'{$this->profile_url}'", "api_url" => "'{$this->api_url}'", "linkedin_token" => "'{$this->linkedin_token}'", "linkedin_token_exp" => "'{$this->linkedin_token_exp}'"); //update the row in the database $db->update($data, 'users', 'id = ' . $this->id); } else { //if the user is being registered for the first time. $data = array("name" => "'{$this->name}'", "linkedin_id" => "'{$this->linkedin_id}'", "pic_url" => "'{$this->pic_url}'", "company_id" => "{$this->company_id}", "profile_url" => "'{$this->profile_url}'", "api_url" => "'{$this->api_url}'", "linkedin_token" => "'{$this->linkedin_token}'", "linkedin_token_exp" => "'{$this->linkedin_token_exp}'"); $this->id = $db->insert($data, 'users'); } if (HttpSession::currentUser()->id == $this->id) { HttpSession::setUser($this); //if this is the loggedin user, lets set the session } return true; }