[eluser]Unknown[/eluser]
I seem to have trouble getting DMZ to work. Either I'm missing something obvious, or I'm just plain doing it wrong. I can't seem to get relationships to work. The tables don't join. What am I doing wrong here?
Datamapper Config (config/datamapper.php)
Code:
$config['auto_populate_has_many'] = TRUE;
$config['auto_populate_has_one'] = TRUE;
Blog Controller (controllers/blog.php)
Code:
public function index()
{
$latest = new Article();
$latest->get();
print_r($latest->all);
$this->output->enable_profiler(TRUE);
}
Articles Model (models/article.php)
Code:
class Article extends DataMapper
{
public $table = 'articles';
public $has_one = array('author');
public function __construct($id = NULL)
{
parent::__construct($id);
}
}
Author Model (models/author.php)
Code:
class Author extends DataMapper
{
public $table = 'authors';
public $has_many = array('article');
public function __construct($id = NULL)
{
parent::__construct($id);
}
}
Profiler Output
Code:
DATABASE: personal QUERIES: 2
0.0129 SELECT * FROM `ci_articles` LIMIT 1
0.0011 SELECT * FROM (`ci_articles`)