<h1>
<?php echo $this->escape($this->nazwa); ?></h1>
<p>
<a href="/zf-tutorial/index/add">Add new album</a>
</p>
<table>
<tr>
<th>Title</th>
<th>Artist</th>
<th> </th>
</tr>
<?php foreach($this->albums as $album) : ?>
<tr>
<td>
<?php echo $this->escape($album->nazwa);?></td>
<td><a href="/zf-tutorial/index/edit/id/
<?php echo $album->id;?>">Edit</a><a href="/zf-tutorial/index/delete/id/
<?php echo $album->id;?>">Delete</a></td>
</tr>
<?php endforeach; ?>
</table>
To jest widok.
Model:
<?php
Zend_Db::ALLOW_SERIALIZATION => false
);
'host' => '127.0.0.1',
'username' => 'root',
'password' => '',
'dbname' => 'download',
'options' => $options
);
$db = Zend_Db::factory('Pdo_Mysql', $params);
$result = $db->fetchOne('SELECT * FROM gd_pliki WHERE id = 21');
Kontroler:
<?php
class HelloController extends Zend_Controller_Action
{
function __construct()
{
parent::__construct();
Zend::loadClass('album');
}
public function init()
{
}
public function indexAction()
{
$view = Zend::registry('view');
$view->title = "My Albums";
$album = new Album();
$view->albums = $album->fetchAll();
$view->actionTemplate = 'index.php';
echo $view->render('site.tpl.php');
}
}
Podejrzewam, że wszystko jest źle, ale właśnie dlatego prosiłem o jakiś przykład. Błąd dostaje taki:
Kod
Fatal error: Declaration of HelloController::__construct() must be compatible with that of Zend_Controller_Action_Interface::__construct() in C:\wamp\www\application\controllers\HelloController.php on line 31