CI_DB_result::row PHP Method

row() public method

A wrapper method.
public row ( mixed $n, string $type = 'object' ) : mixed
$n mixed
$type string 'object' or 'array'
return mixed
    public function row($n = 0, $type = 'object')
    {
        if (!is_numeric($n)) {
            // We cache the row data for subsequent uses
            is_array($this->row_data) or $this->row_data = $this->row_array(0);
            // array_key_exists() instead of isset() to allow for NULL values
            if (empty($this->row_data) or !array_key_exists($n, $this->row_data)) {
                return NULL;
            }
            return $this->row_data[$n];
        }
        if ($type === 'object') {
            return $this->row_object($n);
        } elseif ($type === 'array') {
            return $this->row_array($n);
        } else {
            return $this->custom_row_object($n, $type);
        }
    }

Usage Example

Example #1
0
 /**
  * Authenticate
  *
  * @access	private
  */
 private function _authenticate(CI_DB_result $member, $password)
 {
     $always_disallowed = array(4);
     if ($member->num_rows() !== 1) {
         return FALSE;
     }
     if (in_array($member->row('group_id'), $always_disallowed)) {
         return ee()->output->show_user_error('general', lang('mbr_account_not_active'));
     }
     $m_salt = $member->row('salt');
     $m_pass = $member->row('password');
     // hash using the algo used for this password
     $h_byte_size = strlen($m_pass);
     $hashed_pair = $this->hash_password($password, $m_salt, $h_byte_size);
     if ($hashed_pair === FALSE or $m_pass !== $hashed_pair['password']) {
         return FALSE;
     }
     // Officially a valid user, but are they as secure as possible?
     // ----------------------------------------------------------------
     reset($this->hash_algos);
     // Not hashed or better algo available?
     if (!$m_salt or $h_byte_size != key($this->hash_algos)) {
         $m_id = $member->row('member_id');
         $this->update_password($m_id, $password);
     }
     $authed = new Auth_result($member->row());
     $member->free_result();
     return $authed;
 }
All Usage Examples Of CI_DB_result::row