2008年11月1日星期六

Re: [fw-mvc] _request

Thank you so much for the quick response but it still lists all the type of articles...
 
ArticleController
 
function viewAction(){ 
  $articles = new Articles();
   $type= (int)$this->_request->getParam('type');
$select = $articles->select()->where('type = ?', $type);
 $this->view->articles = $articles->fetchAll($select);
 
view.phtml
<?foreach ($this->articles as $articles): ?>
<tr>
  <th scope="row" class="spec">
  <?php echo $this->escape($articles->type);?></a></th>
  <td><?php echo $this->escape($articles->title);?></td>
  <td><?php echo $this->escape($articles->author);?></td>
  <td><?php echo $this->escape($articles->date_published);?></td>
  <td></td>
</tr>
<?php endforeach;?>
 
 
E
----- Original Message -----
Sent: Saturday, November 01, 2008 11:22 PM
Subject: Re: [fw-mvc] _request

Hi,
FetchAll method requires using select() (http://framework.zend.com/manual/en/zend.db.select.html)
In your situation, it should look something like this:
$articles = new Articles();
 $type= (int)$this->_request->getParam('type');
$select = $articles->select()->where('type = ?', $type);
 $this->view->articles = $articles->fetchAll($select);

--
Aurelijus Valeiša
http://www.Aurelijus.eu


On Sat, Nov 1, 2008 at 11:03 PM, Erdal YAZICIOGLU <erdal.yazicioglu@gmail.com> wrote:
Hello

I am trying to get the request from with type but everytime I am endind up with fetching all the records from database..

The request is coming as
article/view/type/PHP
So under the ArticleController I created a viewAction function as...
$articles = new Articles();
 $type= (int)$this->_request->getParam('type');
 $this->view->articles = $articles->fetchAll('type='.$type);

When I click the article type it still lists me all the articles...Can you guys give me an hint or link to read..

Thanks

没有评论: