In IndexController I retrieves data from the table and sends them to the view. In view I do foreach loops and displays it. One type of data needs to be taken from the database, so the link to the database in a view to get it.
<?php foreach ($this->datas as $data ): >
<div id="<?php echo $data->data_id ?>"></div>
<?php
$Data = Zend_Db::factory('pdo_mysql', $config);
$select = $Data->select()
->FROM('data')
->WHERE('data_id = ?',$data->anchor);
$name = $Data->fetchRow($select);
?>
<span class="nick_name"><?php echo $name?></span>
<?php endif; ?>
How can I avoid connecting to the database in a view?