如何使用Zend DB模型获取非重复值?

时间:2013-12-25 00:14:28

标签: php zend-framework

fetchresultsAction

  public function fetchresultsAction() {
    $this->_helper->layout()->disableLayout();
    $this->_helper->viewRenderer->setNoRender(true);

    //$form_data = $this->getRequest()->getPost();

    //$examcatID = $form_data['examcatID'];
    $examID = 'Exam_ID_001';
    $Exam_Results = new Admin_Model_Examresults();
    $results = $Exam_Results->fetchExamResults($examID);

    foreach ($results as $value) {
        print_r($value['subjectID']);
        echo '<br/>';
    }
}

型号&gt; Examresults

public function fetchExamResults($examID) {

    $sel = $this->select();
    $sel->distinct();


    $sel->where('examID=?', $examID);
    $result = $this->fetchAll($sel);   // fetch the rows to the array called result

    return $result;
}

这段代码不起作用。我需要从mysql数据库中获取subjectID的NON-Duplicate值。我怎么能这样做。请帮我解决这个问题。

注意:这是Zend 1.12版本

1 个答案:

答案 0 :(得分:0)

尝试使用print_r($value->subjectID)