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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:38:14+00:00 2026-06-14T05:38:14+00:00

Why can’t I call methods directly on my object in CodeIgniter? For example: $campaign

  • 0

Why can’t I call methods directly on my object in CodeIgniter?

For example:

$campaign = $this->Campaign_model->get_campaign_from_id($campaign_id);
$campaign->load_settings(); // returns error: Call to undefined method stdClass::load_settings()

The Campaign object is correctly created, but I can’t call methods on it even if it’s within the class.

Here is my Campaign_model method I’m calling:

function load_settings()
{
    echo "test";
    exit;
}

How can I do this kind of operations then? I think I was respecting basic object logic, but I can’t make it work.

  • 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-14T05:38:15+00:00Added an answer on June 14, 2026 at 5:38 am

    CodeIgniter models are just a collection of functions, there is only ever one instance of each model. You don’t return “model objects”, that’s not how it works.

    The “object” you are returning from get_campaign_from_id is just a normal PHP object and has nothing to do with your model.

    You can’t call functions on stdClass objects, but you can pass it to a function that can edit its properties.

    // in PHP5 objects are automatically passed by reference
    function load_settings($obj){
        $obj->test = '123';  // edit a property on the object
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can someone please explain why this doesn't work? MyClass myClass1 = new MyClass(); object
Can i call a Method on the Thread Object ??
Can anyone explain to me why this program: for(float i = -1; i <
Can I run this in a Windows command prompt like I can run it
Can I call select before recv_from on a socket that is blocking?
Can someone maybe tell me why this is not working? I have used echo
Can someone help me with this scenario? *There is a button, which when tapped,
Can't seem to figure out what's wrong with the simple getJSON call below. It's
Can anyone explain me what's going on? I use this method - (BOOL)shouldAutorotateToInterfaceOrientation:( UIInterfaceOrientation)interfaceOrientation
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

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.