[eluser]ianbborg[/eluser]
Solved this problem. I was developing a module in the modules folder and the models where in the modules folder. So I setup a config var named $config['model_path']; which is then added to the path of the autoload function like this:
Now I have another problem with the relationships, table names seem to be duplicated in the query made by DMZ DM Why is this happening(maybe incorrect relationships) :
SELECT general_county.* FROM (general_county) LEFT OUTER JOIN general_county_general_towns_country general_county_general_towns_country ON general_county.id = general_county_general_towns_country.county_id WHERE `general_county_general_towns_country`.`townscountry_id` = 4
Proper Table names are 1.general_towns_country 2.general_country 3.town 4.county
1.general_towns_country Model
Code:
class TownsCountry extends DataMapper
{
public $table ="general_towns_country";
);*/
public $has_one = array('town','country','county');
public function __construct()
{
// model constructor
parent::__construct();
}
}
2.general_country Model
Code:
class Country extends DataMapper
{
public $table ="general_country";
/*public $has_many = array('countryid'=>array('class'=>'townscountry',
'other_field'=>'general_country'
)
);*/
public $has_many = array('townscountry');
public function __construct()
{
// model constructor
parent::__construct();
}
}
3.town Model
Code:
class Town extends DataMapper
{
public $table ="town";
/*public $has_many = array('tid'=>array('class'=>'townscountry',
'other_field'=>'town'
)
);*/
public $has_many = array('townscountry');
public function __construct()
{
// model constructor
parent::__construct();
}
}
4.general_county Model
Code:
class County extends DataMapper
{
public $table ="general_county";
/*public $has_many = array('cid'=>array('class'=>'townscountry',
'other_field'=>'general_county'
)
);*/
var $has_many = array('townscountry');
public function __construct()
{
// model constructor
parent::__construct();
}