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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T15:27:37+00:00 2026-06-05T15:27:37+00:00

I have the following piece of code in my Model: public function getSite() {

  • 0

I have the following piece of code in my Model:

public function getSite()
{
    $this->load->library('site');
    $data = array();
    $str = "SELECT * FROM sitematrix_sites";
    $query = $this->getQuery($str);
    if($query){ 
        foreach($query->result() as $row){
            $site = new Site();
            array_push($data, $site->load($row));
        }

        foreach($data as $site){
            $site->data['database'] = $this->getDatabase($site->data['site_id']);
            $site->data['baseline'] = $this->getBaseline($site->data['site_id']);
        }

        return $data;
    }
    else{
        return false;
    }
}

And I created a class called site:

class Site{

public $data;

public function __contruct(){

    $this->data = ArrayObject(array(), ArrayObject::STD_PROP_LIST);

    $this->data['site_id']                      =   '';
    $this->data['site']                         =   '';
    $this->data['site_code']                    =   '';
    $this->data['tc_10']                        =   array();
    $this->data['tc9x']                         =   array();
    $this->data['tc8x']                         =   array();
    $this->data['tc2008']                       =   array();
    $this->data['eng_2005']                     =   array();
    $this->data['database']                     =   array();
    $this->data['baseline']                     =   array();

However, I’m getting the following error:

<p>Severity: Notice</p>
<p>Message:  Trying to get property of non-object</p>
<p>Filename: models/sitematrix_model.php</p>
<p>Line Number: 77</p>

Any thoughts? I have tried to access those values either as $site->data->database and as $site->data['database'] but both don’t work.

line 77:  $site->data['database'] = $this->getDatabase($site->data['site_id']);

The function getDatabase:

public function getDatabase($id){
    $database = array();
    $str = "SELECT * FROM site_database where site_id='$id'";
    $query = $this->getQuery($str);
    if($query){
        foreach($query->result() as $row){
            array_push($database, $row->name);
        }
    }

    return $database;
}

Function getQuery:

public function getQuery($str){
    $data = array();
    $query = $this->db->query($str);

    if(!$query || $query->num_rows() == 0){
        return false;
    }
    return $query;
}

Thanks

  • 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-05T15:27:38+00:00Added an answer on June 5, 2026 at 3:27 pm

    I’m pretty sure your error message is complaining about the

    $this->getDatabase

    part of that line, not the $site-> aspect.

    Are all of these functions on the Model, not the Class site?

    when you are working in the model, $this-> has to stick to functions & vars from that class

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

Sidebar

Related Questions

I have the following piece of code from a book. There is this function
I have following piece of code : public Hashmap<String,String> tempmap = new HashMap<String,String>(); and
I have the following piece of code: class Foo { public Foo() { Bar
I have the following piece of code: $(document).ready(initialize); function initialize() { $('#btnPoint').css('width', $('#btnPoint').width()); }
I have this piece of code: @RequestMapping(value = /test.json, method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) public
I have the following piece of code overriding the save method of a model:
I have the following piece of code: public List<myTask> MyTask { get; set; }
I have following piece of code: class Test{ private: int id; public: Test(int v):id(v)
I have following piece of code which posts some data into database: $post =
I have the following piece of code: inc(integer(DestPixel), DestDelta); //DestPixel: PColorRGB; DestDelta: integer; 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.