I'm trying to mimic these simple PHP class definitions in CI
<?php
class Student
{
private $name;
public function __construct($name) {
$this->name = $name;
}
public function getName() {
return $this->name;
}
}
class SportsStudent extends Student {
private $sport;
public function __construct($name) {
parent::__construct($name);
$this->sport = "Tennis";
}
public function getSport() {
return $this->sport;
}
}
$s1 = new Student("Joe Bloggs");
echo $s1->getName() . "<br>";
$s2 = new SportsStudent("John Smith");
echo $s2->getName() . "<br>";
echo $s2->getSport() . "<br>";
?>
I'd like to know how to best approach it, I did try creating a controller for both classes, but had trouble with inheritance, I was told it was best to extend the CI_Controller but couldn't get my head around it, it seemed overkill and wasn't recommended.
Is it best to just keep these standard classes and call them from my controller?
This is my first MVC based attempt at a system, and my first CI project, it would be nice to have some pointers.