0

I have the following code:

$this->load->model('funders_model');

        $funders = $this->funders_model->getAllLike($name);

        $opportunities = array();

        foreach($funders as $funder) {

            $query = "SELECT funding_opportunities.id FROM funding_opportunities WHERE funder = " . $funder->id;

            $exec_query = $this->db->query($query);

            $row = $exec_query->row();


            $funding_opportunity = $this->getFromId($row->id);

            if(!is_null($funding_opportunity))
                $opportunities[] = $funding_opportunity;

        }


        return $opportunities;

What the code does is it gets an array of 'funder' objects and, for each, retrieves a 'funding_opportunity' object.

My problem is that when I try adding the opportunity to the $opportunities array, each loop cycle overwrites the previous one.

I tried using the 'clone' call on $funding_opportunity before adding it, but to no avail.

Any thoughts?

MrD
  • 4,986
  • 11
  • 48
  • 90

0 Answers0