[eluser]LeePR[/eluser]
I'm having a little problem with a custom library. I have a StateCollection class that extends a Collection class. When I load the StateCollection library, the code in the constructor executes, but when I try to call one of the methods (inherited from Collection), I get an error:
Quote:Severity: Notice
Message: Undefined property: CI_Loader::$statecollection
Filename: views/stateList.php
Line Number: 3
Is the code in my Collection/StateCollection class at fault? Here's the code...
Collection (library):Code:
<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');
class Collection {
public $arrCollection = array();
public $CI;
public function __construct() {
// Empty constructor.
}
public function Collection() {
$this->__construct();
}
public function hasNext() {
// Later.
}
public function getNext() {
// Later.
}
public function getCollection() {
return $this->arrCollection;
}
public function add($object) {
$arrCollection[] = $object;
}
}
?>
StateCollection (library):Code:
<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');
require_once('Collection.php');
require_once('State.php');
class StateCollection extends Collection {
public function __construct() {
parent::__construct();
$this->CI =& get_instance();
$this->populate();
}
public function Collection() {
$this->__construct();
}
public function populate() {
$this->CI->load->database();
$sql = "SELECT lst_id, lst_code, lst_name " .
"FROM rsfs_lookup_state";
$query = $this->CI->db->query($sql);
foreach ($query->result() as $row) {
$collection[] = new State($row->lst_id);
}
}
}
?>
stateList (view):Code:
<?php
$this->load->library('StateCollection');
$states = $this->statecollection->getCollection(); // Undefined property: CI_Loader::$statecollection
?>
Can anyone offer some guidance?
Cheers,
LeePR