在Zend Framework中加入表抛出应用程序错误

时间:2013-10-27 13:55:49

标签: php zend-framework jointable

将Zend Framework库升级到1.12后出现此问题。它在1.11版本上运行良好。

问题是当我加入两个表时,我收到了这个错误:

  

申请错误

     

例外信息:

     

消息:指定的表与行

的列不同

此错误由Zend / Db / Table / Row / Abstract.php生成(第356行

我的表格结构

Members:
  id (int)
  name (varchar)
  age (int)
  family_id (varchar)

Family:
  id (int)
  family_type (varchar)

我的模特:

class Model_Member extends Zend_Db_Table_Abstract
{
    public function getAll($params = array())
    {
        $select = $this->select();
        $select->setIntegrityCheck(false);

        $select->from("members", array('name', 'family_id'));
        $select->join('family', 'family.id = members.family_id', array('family_type'));

        $paginator = Zend_Paginator::factory($select);
        $paginator->setItemCountPerPage(20);
        $paginator->setCurrentPageNumber(1);
        $paginator->setPageRange(10);

        return $paginator;
    }
}

然后在我的视图文件中

foreach($this->paginator as $row)
{
}

1 个答案:

答案 0 :(得分:0)

在你的模特中试试这个:

    class Model_Member extends Zend_Db_Table_Abstract
    {
    public function getAll($params = array(), $paged = 1)
   {
    $select = $this->select();
    $select->setIntegrityCheck(false);

    $select->from("members", array('name', 'family_id'));
    $select->join('family', 'family.id = members.family_id', array('family_type'));

    $adapter = new Zend_Paginator_Adapter_DbTableSelect($select);
    $paginator = new Zend_Paginator($adapter);
    $paginator->setItemCountPerPage(5)
              ->setCurrentPageNumber((int) $paged);

    return $paginator;
    }
 }

并查看:

<?php if($this->data instanceof Zend_Paginator): ?>
                               <?php echo $this->paginationControl($this->data,
                                                                     'Sliding',
                                                                            'pathToController/_paginator.phtml', array('params'=>$params);?>// if you want pass some params. 

应该在你的App上工作,正在努力。