[eluser]charme[/eluser]
Hi everyone.
I just started with CI and got a problem in realizing a small sample application.
I made an abstract class which extends model. I made this as a base class for my application.
Then i extend a class from that abstract class. And now the problems begin.
If I dont include the abstract class in the new class, i get the error that my abstract class wasnt found. Both are available in the models folder.
The next thing is, if i use a controller which has the same name like the class it is made for. Then i receive a "Cannot redeclare class" error.
I use xampp 1.7.3 and CI 1.7.2
Thank you !
Here is the code of the classes:
Code:
abstract class GObject extends Model{
var $id;
var $ObjectState;
protected function __construct() {
parent::Model();
//$this->load->database();
}
public function getId() {
return $this->id;
}
public function setId($id) {
$this->id = $id;
}
public function getObjectState() {
return $this->ObjectState;
}
public function setObjectState($ObjectState) {
$this->ObjectState = $ObjectState;
}
public abstract function getAll();
}
?>
Code:
include_once 'GObject.php';
class Kunde extends GObject{
function Kunde(){
parent::__construct();;
}
public function getAll(){
$q = $this->db->get('Kunde');
if($q->num_rows() > 0){
foreach ($q->result() as $row){
$data[] = $row;
}
return $data;
}
}
}
Code:
class Kunde extends Controller{
function Kunde(){
parent::Controller();
//$this->load->scaffolding('Kunde');
}
function index(){
$this->load->model('Kunde');
$data['query'] = $this->Kunde->getAll();
$this->load->view('view_kunde', $data);
}
}