Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5990371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:14:05+00:00 2026-05-22T23:14:05+00:00

In my model named Profile_model I have this function which retrieves profile data for

  • 0

In my model named Profile_model I have this function which retrieves profile data for the logged in user.

function profile_read()
{
    $this->db->where('user_id', $this->tank_auth->get_user_id());
    $query = $this->db->get('user_profiles');
    $data['row'] = $query->row();
}

In my controller I’m using $this->load->view('profile/edit_general_view', $data); to try and load the data from the model into the view.

function edit_profile()
{       

    //validation rules
    $this->form_validation->set_rules('first_name', 'First Name', 'trim|required|xss_clean|min_length[2]|max_length[20]|alpha');
    $this->form_validation->set_rules('last_name', 'Last Name', 'trim|required|xss_clean|min_length[2]|max_length[20]|alpha');


    if ($this->form_validation->run() == FALSE) //if validation rule fails
    {           
        $this->load->view('profile/edit_general_view', $data); //load data from model in view
    }
    else //success
    {
        $send_to_db = array (                   
                'first_name'    => $this->input->post('first_name'),
                'last_name'     => $this->input->post('last_name')
        );
        $seg = 'edit';
        $this->load->model('Profile_model');
        $this->Profile_model->profile_update($send_to_db, $seg);            
    }
}

What is the correct way to pass the data from the model function profile_read into my controller function?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T23:14:06+00:00Added an answer on May 22, 2026 at 11:14 pm

    Time to read about variable scopes:
    http://php.net/manual/en/language.variables.scope.php

    The $data variable in the model method isn’t accessible to the controller. Have the model method return an actual array of data.. eg:

    function profile_read()
    {
        $this->db->where('user_id', $this->tank_auth->get_user_id());
        $query = $this->db->get('user_profiles');
        return ($query ? $query->row : FALSE);
    }
    

    And then in the controller, store that in the ‘data’ for the view.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a user model which has_one profile. The user model has a name
Let's say I have this model named Product with a field named brand .
How do we build a profile page that outputs the user's data? and this
I have a profile class: class profile(db.Model): user = db.stringProperty() # Other properties ...
I have model Person or say Profile and this class Person has a genericRelationship
I have a user model that has_one profile, and the profile belongs to the
I have user profile model with M2M field class Account(models.Model): ... friends = models.ManyToManyField('self',
Given these two models: class Profile(models.Model): user = models.ForeignKey(User, unique=True, verbose_name=_('user')) about = models.TextField(_('about'),
I have this function on my controller (Im using CodeIgniter) that reads the database,
I have the following models: class Application(models.Model): users = models.ManyToManyField(User, through='Permission') folder = models.ForeignKey(Folder)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.