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 7615181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T02:35:03+00:00 2026-05-31T02:35:03+00:00

My CodeIgniter model method grabs all of the cases with a specific subcategory. Then

  • 0

My CodeIgniter model method grabs all of the “cases” with a specific subcategory. Then it’s suppose to translate those into a new array with proper “get_case” results but it keeps returning the same array element. Every associated method I debug seems to be functioning properly on its own, but in this function I get the same result repeated.

here is the method/function I am having trouble with… This seems like it should be simple

function get_subcategories_cases($subcategory)
    {
    $this->db->order_by('sortorder','asc');
    $this->db->where('subcategoryid', $subcategory);
    $query = $this->db->get('cases');
    $query = $query->result();
    //
    $outputArray = array();
    foreach ($query as $item) {
    array_push($outputArray, $this->get_case($item->id));
    }
    return $outputArray;
    }

here is the get_case method

function get_case($id)
{
//print_r($id);
$this->db->where('id', $id);
$this->db->limit(1);
$query = $this->db->get('cases');
$query = $query->row();
//
$this->id               = $query->id;
$this->sortoder         = $query->sortorder;
$this->surgeonid        = $query->surgeonid;
$this->subcategoryid    = $query->subcategoryid;
$this->age              = $query->age;
$this->gender           = $query->gender;
$this->typeofsurgery    = $query->typeofsurgery;
$this->isactive = $query->isactive;
$this->isfeatured       = $query->isfeatured;
$this->iswarning        = $query->iswarning;
$this->metatitle        = $query->metatitle;
$this->metadescription  = $query->metadescription;
$this->metakeywords     = $query->metakeywords;
$this->casedescription  = $query->casedescription;
$this->photos       = $this->insert_case_photos($query->photos);
//
return $this;
}
  • 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-31T02:35:04+00:00Added an answer on May 31, 2026 at 2:35 am

    When you are saving the results in get_case() to $this, you are saving them to the model (object) attributes, which have scope outside of the get_case() method, so it maybe something to do with that.

    Try saving the query result to a local variable:

    function get_case($id)
    {
        //print_r($id);
        $this->db->where('id', $id);
        $this->db->limit(1);
        $query = $this->db->get('cases');
        $case = $query->row();
        //
        $case->photos = $case->insert_case_photos($case->photos);
        //
        return $case;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using CodeIgniter and I got a model that fetches let's say all recipes
I've written a new model for my CodeIgniter framework. I'm trying to load the
I am new to codeigniter and I am having some issues loading a model
CodeIgniter has a method $this->load->vars($array) that is ideally used in the parent Controller to
Can one call a method from another model in a model in CodeIgniter? I
It used to be that within a CodeIgniter model you couldn't access another model.
I am writing a webapp using CodeIgniter that requires authentication. I created a model
When a user is logged into my CodeIgniter application, I need a list of
In this codeigniter model, I am trying to push the category name of each
Okay so, I'm working with CodeIgniter. posts.php is my view that displays all the

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.