2010年12月28日星期二

[fw-db] Db Select prints wrong info

Good day all

I have a model called articles where I try to pull all pending ones

public function pendingArticles(){
$approved='0';
$select = $this->select()
->setIntegrityCheck(false)
->from(array('a' => 'dict_articles'))
->join(array('b' => 'dict_categories'),'a.categoryID =
b.categoryID')
->join(array('c' => 'dict_users'),'a.userID = c.userID')
->where('a.approved=?',$approved);
return $this->fetchAll($select);

}

In the controller I call this method as follows.

public function pendingArticleAction(){
$articles = new Application_Model_DbTable_Articles();
$this->view->articles = $articles->pendingArticles();
}

In the view as usual I put the articles in foreach loop and try to print
articles where approval status is 0.

<?php
foreach ($this->articles as $articles):
echo $articles->approved;
endforeach;
?>

It prints 1 instead of 0s for the pending articles.

I am using ZF 1.11

Any hints..?

Best Regards
E

没有评论: