English 中文(简体)
经由Zentd Paginator进行的假肢
原标题:pagination through Zend Paginator giving error

i 在我这里的感想中,正在使用zen的假肢。

public function listAction(){
      $registry = Zend_Registry::getInstance();  
      $DB = $registry[ DB ];
      $sql = "SELECT * FROM `task` ORDER BY task_name ASC";
      $result = $DB->fetchAll($sql);
      $page=$this->_getParam( page ,1);
      $paginator = Zend_Paginator::factory($result);
      $paginator->setItemCountPerPage(3);
      $paginator->setCurrentPageNumber($page);
      $this->view->paginator=$paginator;
  }

这也是采取这一行动的观点。

 <table border="1" align="center">
<tr>
  <th>Task Name</th>      
  <th>Task Assign To</th>  
  <th>Action</th>     
</tr>
   <?php
    foreach($this->paginator as $record){ ?>
    <tr> 
   <td><?php echo $record[ task_name ]?></td>
  <td><?php echo $record[ task_assign ]?></td>  

  <td>
    <a href="edit/id/<?php echo $record[ id ]?>">Edit</a>
    |
    <a href="del/id/<?php echo $record[ id ]?>">Delete</a>      
  </td>   
</tr> 
   <?php } ?>
  </table>
   <?php echo $this->paginationControl($this->paginator,  Sliding ,  pagination.phtml ); ?>

给我这个错误

Fatal error: Cannot use object of type stdClass as array in C:xampphtdocszend_loginapplicationviewsscripts	asklist.phtml on line 47

第47条

 <td><?php echo $record[ task_name ]?></td>

(i) 将物体改为阵列

function objectToArray( $object ){
 if( !is_object( $object ) && !is_array( $object ) ){
  return $object;}
 if( is_object( $object ) ){
 $object = get_object_vars( $object );}
return array_map(  objectToArray , $object );}
$paginator = objectToArray($this->paginator);

我现在要修改我的法典。

foreach($paginator as $record){

以及

   <?php echo $this->paginationControl($paginator,  Sliding ,  pagination.phtml ); ?>

但它现在给我这个错误。

 Catchable fatal error: Argument 1 passed to Zend_View_Helper_PaginationControl::paginationControl() must be an instance of Zend_Paginator, array given in C:xampphtdocszend_loginlibraryendViewHelperPaginationControl.php on line 88

can you please tell what i am missing i am new to zend so please dont mind my awkward question this is my ErrorController.php

class ErrorController extends Zend_Controller_Action{
public function errorAction()
{
    $errors = $this->_getParam( error_handler );

    switch ($errors->type) {
        case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE:
        case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
        case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:

            // 404 error -- controller or action not found
            $this->getResponse()->setHttpResponseCode(404);
            $this->view->message =  Page not found ;
            break;
        default:
            // application error
            $this->getResponse()->setHttpResponseCode(500);
            $this->view->message =  Application error ;
            break;
    }

    // Log exception, if logger available
    if ($log = $this->getLog()) {
        $log->crit($this->view->message, $errors->exception);
    }

    // conditionally display exceptions
    if ($this->getInvokeArg( displayExceptions ) == true) {
        $this->view->exception = $errors->exception;
    }

    $this->view->request   = $errors->request;
}

public function getLog()
{
    $bootstrap = $this->getInvokeArg( bootstrap );
    if (!$bootstrap->hasPluginResource( Log )) {
        return false;
    }
    $log = $bootstrap->getResource( Log );
    return $log;
}
}
最佳回答

你只是需要把它称作一个目标:

<td><?php echo $record->task_name; ?></td>

最新资料:在聊天中解决的所有其他错误

问题回答

暂无回答




相关问题
Zend 邮件问题,涉及外国char子+ com子

泽斯德邮局在名称被定为具有外国性质(如“保”)和 com(”)的物品时,就放弃了一种例外(因为邮局(邮局)退回假)。 重新提出以下守则。

PHP Framework: Ebay Like Site

I am going to be builiding a site like ebay - with all the features of ebay. Please note my payment method is limited to paypal. What would be the best PHP framework to use to build this quickly, ...

Link to a specific step in onepage checkout

Is it possible to redirect the browser to nth step in the onepage checkout? If so, how would one go about doing it? I m working on a payment module and have a sort of "cancel" action that i would ...

Tagging with Zend Framework

I m trying to create the same solutions as below, but using a simple MySQL query (instead of the static version used below where the words/tags are implemented in the code). The name of the MySQL ...

dynamicaly adding textboxes to zend_form

I hope that this is a quick question to answer. I am developing a form using Zend_Form, I have a number of Zend_Dojo_Form_Element_Textboxs to add to this form dynamically. These are added from rows ...

热门标签