0

将 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)
{
}
4

1 回答 1

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. 

应该在你的应用程序上工作,在我的应用程序上工作。

于 2013-10-28T07:16:38.127 回答