Пагинация на страницы и поисковый запрос Cakephp 3.8

Я использую пагинацию и поисковый запрос, но когда я перехожу на страницу 3, а затем использую для поиска любого запроса, cakephp дает мне исключение времени выполнения, как я могу его разрешить? Вот код: метод индекса и файл ctp индекса

public function index()
{
  $key =''; 

  if($this->request->is('post')) {
        $key = $this->request->data['search'];
  }

  // $this->request->is('ajax');
  // $keyword = $this->request->query('keyword'); 
  $BusinessAdded = TableRegistry::get('addBusiness');
  $query = $BusinessAdded->find()
                             ->contain(['businesscategory','users','subcategory','businessimg'])
                             ->where([ 'subcategory.categoryname LIKE'=>'%'.$key.'%'])
                              ->orwhere(['businesscategory.categoryname LIKE'=>'%'.$key.'%'])
                              ->orwhere(['description LIKE'=>'%'.$key.'%']);
                             //print_r($query);die;
                             $this->paginate =[
                                  'addBusiness' => [
                                      'limit' => 3,
                                      ],
                                  ];
                             $BusinessData = $this->paginate($query);              
           //print_r( $this->paginate($query));die;           
          $this->set(compact('BusinessData'));

          }

'''

2.index.ctp '' '

   <?php echo $this->Form->create("users");?>
    <?= $this->Form->control('search') ?> 
    <?= $this->Form->button(__('submit')) ?>
   <?php echo $this->Form->end();?>
<!-- Search Box End -->
<!-- Business Cards -->
<div class="table-content">
      <table>
        <tr>
 <?php foreach($BusinessData as $business) {  
      $img = $business->businessimg;
      foreach($img as $imgs) { ?><td>
      <div class="card" style="width: 18rem;">
      <!-- Images slider -->
      <img src="/itfox/webroot/img/business/<?php echo $imgs['images'] ?>" alt="<?php echo $business->businessname; }?>" class="card-img-top"/>
      <!-- Images Slider -->
      <div class="card-body">
         <h5 class="card-title"><?php echo $business->businessname  ?></h5>
         <p class="card-text"><?php echo $business->description  ?> </p>
     </div>
     <ul class="list-group list-group-flush">
         <li class="list-group-item"><?php echo $business->businesscategory->categoryname;  ?></li>
          <li class="list-group-item"><?php echo $business->subcategory['categoryname'] ; ?></li>
           <li class="list-group-item"> <?php echo $business->phone; ?></li>
      </ul>
      </div></td>
<?php } ?>
</tr>
</table>
</div>
    <!-- Pagination -->   
    <?php
                echo "<div class='center'><ul class='pagination' style='margin:20px auto;'>";
                echo $this->Paginator->prev('< ' . __('previous'), array('tag' => 'li', 'currentTag' => 'a', 'currentClass' => 'disabled'), null, array('class' => 'prev disabled'));
                echo $this->Paginator->numbers(array('separator' => '','tag' => 'li', 'currentTag' => 'a', 'currentClass' => 'active')); 
                echo $this->Paginator->next(__('next').' >', array('tag' => 'li', 'currentTag' => 'a', 'currentClass' => 'disabled'), null, array('class' => 'next disabled'));
                echo "</div></ul>";
            ?>
 <?= $this->Paginator->counter() ?>
'''

выполнение ошибки во время выполнения

0 ответов

Другие вопросы по тегам