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

  • SEARCH
  • Home
  • 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 8174505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T22:28:37+00:00 2026-06-06T22:28:37+00:00

In codeigniter, I retrieve database results and store it in a variable like the

  • 0

In codeigniter, I retrieve database results and store it in a variable like the following:

$data['user'] = $this->some_model->get_by_id($id);

Say the above retrieves only the user_id and the user_name, so the variables will be

$data['user']->user_id;

$data['user']->user_name;

Now, say, I want to assign another value (eg. age), can I do the following?

$data['user']->age = '23';
  • 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-06-06T22:28:38+00:00Added an answer on June 6, 2026 at 10:28 pm

    Technically, yes, you can. But it’s bad practice. Assigning values to undeclared object properties is “expensive” in PHP. Plus it is not always clear to the reader where a value came from so this make code maintenance more difficult.

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

Sidebar

Related Questions

Using Codeigniter, any numeric data returned from my MySQL database is returned as strings.
How can I retrieve data from the database by querying records between two dates
I am using code igniter to retrieve data from a database What is returned
I am using code igniter to retrieve data from a database What is returned
I use codeigniter's session class with the option to store session data in a
CodeIgniter allows access to POSTed data via: $this->input->post('input_name'); where 'input_name' is the name of
I'm trying to retrieve a url sent in the query strings in a codeigniter
Codeigniter won't redirect the url oauth://application properly, pinning it after the current domain like
In CodeIgniter I would do: print_r ($this->db->queries); In Yii I tried: print_r (Yii::app()->db) But
In CodeIgniter I'm using a base CRUD My_model , but I have this small

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.