/** * Method to load a User object by user id number. * * @param mixed $identifier The user id of the user to load. * * @return $this Method allows chaining * * @since 1.0 * @throws \RuntimeException */ public function load($identifier) { // Create the user table object $table = new UserTable(null, null, $this->database); // Load the User object based on the user id or throw a warning. if (!$table->load($identifier)) { // Reset to guest user $this->guest = 1; throw new \RuntimeException('Unable to load the user with id: ' . $identifier); } // Assuming all is well at this point let's bind the data foreach ($table->getFields() as $key => $value) { if (isset($this->{$key}) && $key != 'params') { $this->{$key} = $table->{$key}; } } $this->params->loadString($table->params); // The user is no longer a guest if ($this->id != 0) { $this->guest = 0; } else { $this->guest = 1; } return $this; }