I have a base controller which has base methods
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class MY_Championship extends CI_Controller {
protected $championship_id;
public function __construct($_championship_id)
{
parent::__construct();
$championship_id = $_championship_id;
}
public function results($page)
{
//Some code here
}
}
And when I try to implement My_Championship class in another controller the output is empty even when I pass parameter '1' in the constructor
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
require_once("application/core/MY_Championship.php");
class Eurobasket2017 extends MY_Championship {
public function __construct()
{
parent::__construct(1);
file_put_contents("test.txt", $this->championship_id);
}
}
The main problem is that depending on which parameter I give the constructor it changes records from the database: for example if I give parameter 1 it loads eurobasket games and if I give parameter 2 it loads nba games and so on..
Class MY_Championship constructor does not update its own instances championship_id property
change
$championship_id = $_championship_id;
into
$this->championship_id = $_championship_id;
If you don't do this the $championship_id var will be lost as soon as the parent constructor is finished.