@toopay; Thanks for your reply.
I’m using the following models (simplified version);
Model 1 (Company);
<?php namespace Model;
use \Gas\Core;
use \Gas\ORM;
class Company extends ORM {
public $primary_key = 'id';
function _init()
{
// Define relationships
self::$relationships = array(
'businessunit' => ORM::has_many('\\Model\\Businessunit')
);
self::$fields = array(
'id' => ORM::field('auto[10]'),
'name' => ORM::field('char[200]'),
'created_at' => ORM::field('datetime'),
'modified_at' => ORM::field('datetime'),
);
}
}
Model 2 (Businessunit);
<?php namespace Model;
use \Gas\Core;
use \Gas\ORM;
class Businessunit extends ORM {
public $primary_key = 'id';
function _init()
{
self::$relationships = array (
'company' => ORM::belongs_to('\\Model\\Company')
);
self::$fields = array(
'id' => ORM::field('auto[10]'),
'name' => ORM::field('char[200]'),
'created_at' => ORM::field('datetime'),
'modified_at' => ORM::field('datetime'),
);
}
}
The businessunit database table has a field company_id.
The controller;
class Test extends CI_Controller {
public function __construct() {
parent::__construct();
//$this->output->enable_profiler(TRUE);
}
public function index(){
$companies = Model\Company::all();
print_r($companies);
}
}
But isn’t it an php fundamental instantiating an abstract class is illegal?
From the php manual:
Classes defined as abstract may not be instantiated,....
http://php.net/manual/en/language.oop5.abstract.php
Or is it not the intention to instantiate “gas/orm”? I think it is happening in line 830;
$gas = self::make();
If i get it right, this line results in the instantiation of “abstract class ORM” (which is illegal?).
