Hello,
i'm trying to read from 3 tables..
blog_article:
id - name - text - category_id - author_id - tags - published - commentable
- date
blog_category:
id - name
user_be:
id - name - first_name - last_name
Here my Code for the Models:
ArticleModel
class admin_models_BlogarticleModel extends Zend_Db_Table_Abstract {
protected $_name = 'blog_article';
protected $_referenceMap = array(
'Author' => array(
'columns' => array('author_id'),
'refTableClass' => 'user_models_UserModel',
'refColumn' => 'id'
),
'Category' => array(
'columns' => array('category_id'),
'refTableClass' => 'admin_models_BlogcategoryModel',
'refColumn' => 'id'
)
);
public function getBlogarticles($param = 'all', $value = null) {
switch ($param) {
case 'all':
$select = $this->fetchAll();
break;
case 'date':
$where = 'date=' . $value;
$select = $this->fetchAll($where);
break;
case 'category':
$where = 'category_id' . $value;
$select = $this->fetchAll($where);
break;
}
return $select;
}
}
?>
The UserModel:
<?php
class user_models_UserModel extends Zend_Db_Table_Abstract {
protected $_name = 'user_be';
protected $_dependentTables = array('blog_article');
public function getUser($id) {
$where = 'id=' . $id;
$select = $this->fetchAll($where);
return $select;
}
}
?>
The CategoryModel:
<?php
class admin_models_BlogcategoryModel extends Zend_Db_Table_Abstract {
protected $_name = 'blog_category';
protected $_dependentTables = array('blog_article');
public function getBlogcategory() {
$select = $this->fetchAll();
return $select;
}
}
?>
This Code is the call in the Controller:
public function listArticleAction() {
$blogarticle = new admin_models_BlogarticleModel();
$this->view->blogarticle = $blogarticle->getBlogarticles();
}
My Problem is, that in the view i'm iterating all entries by
foreach($this->blogarticle as $blogarticle)
It would be nice, if i could do something like this: <?php echo
$blogarticle->author_name; ?>
Thanks a lot!
Dennis
--
View this message in context:
http://www.nabble.com/Zend_Db_Table%3A%3AReferences-tp16692783p16692783.html
Sent from the Zend Framework mailing list archive at Nabble.com.