I just started to use Zend so I'm quiet a newbie with it.
Here my Question:
I got to tables
-mod_onair (id,from,to,moderator)
-moderatoren (f_id,f_photo,f_name)
Now i wanna connect them mod_onair.moderator = moderatoren.f_id
And then id like to get the view of the name and image.
DB Model:
<?php
class Application_Model_DBTable_OnAir extends Zend_Db_Table_Abstract
{
protected $_name = 'mod_onair';
}
?>
IndexController:
<?php
class IndexController extends Zend_Controller_Action
{
public function init()
{
}
public function indexAction()
{
$onair = new Application_Model_DBTable_OnAir();
$select = $onair->select()
->setIntegrityCheck(false)
->from(array('o' => 'mod_onair'),
array('von', 'bis','moderator'))
->join(array('m' => 'moderatoren'),
o.moderator = m.f_id')
->where('(mod_onair.von < NOW()) AND (mod_onair.bis > NOW())');
$this->view->onair = $onair->fetchAll($select);
}
}
View Script:
<?php foreach($this->onair as $onair) : ?>
"...<?php echo $this- escape($onair->m.f_foto);?>" width="150px"><br>
<h3><?php echo $this->escape($onair->m.f_name);?></h3>
<?php echo $this->escape($onair->o.von);?>-><?php echo
$this->escape($onair->o.bis);?><br>
<?php endforeach; ?>
--
View this message in context: http://zend-framework-community.634137.n4.nabble.com/InnerJoin-or-JoinLeftProblem-tp3260142p3260142.html
Sent from the Zend DB mailing list archive at Nabble.com.
没有评论:
发表评论