2013-06-30 2 views
1

저는 Zend-Framework의 세계에 새로운 경험이 있으며 zend-framework에있는 사이트를 인수했습니다. 현재 페이지 중 하나에 버그가 있으며 알아낼 수 없습니다. 나는 Zend Paginator와 관련이 있다고 생각하지만, 확실하지는 않습니다. Zend-Paginator를 사용하는 동안 데이터베이스에서 내 행 목록을 가져 오는 방법

내가 가진 문제가 있습니다 섹션의 컨트롤러에 코드입니다 :

나는 목록에 데이터베이스에있는 웹 사이트를 호출하는 코드를 가지고있는 PHP 페이지에서
$currentPage = $this->_getParam('page'); 
$numWebsitesFullOnline = $websites->getWebsitesFullOnline(); 

$select = $websites->select(); 
$select->setIntegrityCheck(false); 
$select->from(array('w' => 'websites'), array('id', 'online', 'kw_adjective', 'kw_name', 'kw_location', 'url', 'email', 'address', 'ftp_server', 'ftp_username', 'ftp_password', 'ftp_folder', 'phone_number', 'indexed', 'youtube_position', 'twitter_user', 'facebook_id', 'video_made', 'image1_id', 'image2_id', 'image3_id', 'bg_color', 'dark_color', 'light_color', 'links_color', 'text_color', 'google_account', 'ganalytics', 'gmaps_status', 'google_position', 'gmap_position', 'hp1', 'hp2', 'hp3', 'hp4', 'hp5', 'hp6', 'hp7', 'hp8', 'hp9', 'hp10', 'about1_id', 'about2_id', 'about3_id', 'tip1_id', 'tip2_id', 'tip3_id', 'contact_texts_id', 'quote_texts_id', 'demographics_id')) 
    ->join(array('d' => 'demographics'), 'w.demographics_id = d.id', array('total_population')) 
    ->order(array('total_population DESC', 'kw_location')); 
$paginator = new Zend_Paginator(new Zend_Paginator_Adapter_DbSelect($select)); 
$paginator->setItemCountPerPage(50); 
$paginator->setCurrentPageNumber($currentPage); 
$paginator->setPageRange(($paginator->getTotalItemCount()/50) + 1); 
$this->view->paginator = $paginator; 

$numWebsitesOnline = $websites->getWebsitesOnline(); 

:

<p class="red"> 
Websites online: <?php echo $this->numOnline; ?> 
</p> 

<?php print_r(count($this->paginator)); ?> 

<?php if(count($this->paginator)): ?> 

<table class="table-list"> 
<?php foreach($this->paginator as $item): ?> 
    <tr> 
     <?php if($this->userIsAllowedAction('websites', 'reload')): ?> 
     <td class="center noborder w30"> 
      <img class="hidden" src="<?php echo $this->baseUrl() . '/images/loader.gif' ?>" alt="Loading..."/><a class="reload" title="refresh" href="<?php echo $this->baseUrl(); ?>/utils/ui/refresh-website.php" rel="<?php echo urlencode('http://' . $item['url'] . '/install.php'); ?>,<?php echo urlencode($item['ftp_server']); ?>,<?php echo $item['ftp_username']; ?>,<?php echo $item['ftp_password']; ?>,<?php echo $item['ftp_folder']; ?>,<?php echo $this->baseUrl(); ?>,<?php echo $item['id']; ?>"><img src="<?php echo $this->baseUrl(); ?>/images/icon-refresh.png" alt="Refresh"/></a> 
     </td> 
     <?php endif; ?> 
     <td class="center noborder w30"> 
      <?php if($this->userIsAllowedAction('websites', 'edit')): ?><a title="Edit" href="<?php echo $this->url(array('controller' => 'websites', 'action' => 'edit', 'id' => $item['id'])); ?>"><img src="<?php echo $this->baseUrl(); ?>/images/icon-edit.png" alt="Edit"/></a><?php endif; ?> 
     </td> 
     <td class="center noborder w30"> 
      <?php if($this->userIsAllowedAction('websites', 'remove')): ?><a title="Remove" href="<?php echo $this->url(array('controller' => 'websites', 'action' => 'remove', 'id' => $item['id'])); ?>"><img src="<?php echo $this->baseUrl(); ?>/images/icon-delete.png" alt="Remove"/></a><?php endif; ?> 
     </td> 
     <td> 
      <?php if($item['online']): ?> 
       <span class="hidden"><?php echo trim($this->escape($item['kw_adjective'] . $item['kw_name'])); ?></span><a class="goto-website" href="http://<?php echo $item['url']; ?>" target="_blank"><?php echo $this->escape($item['kw_location']); ?></a> 
      <?php else: ?> 
       <?php echo $this->escape($item['kw_location']); ?> 
      <?php endif; ?> 
     </td> 
     <td class="center population"> 
      <?php if($item['total_population'] >= 0) echo $item['total_population']; ?> 
     </td> 
     <td class="center"> 
      <?php if(!empty($item['url'])): ?><img src="<?php echo $this->baseUrl(); ?>/images/check_mark.png" alt="DONE"/><?php endif; ?> 
     </td> 
     <td class="center"> 
      <?php if(!empty($item['email'])): ?><img src="<?php echo $this->baseUrl(); ?>/images/check_mark.png" alt="DONE"/><?php endif; ?> 
     </td> 
     <td class="center"> 
      <?php if($item['demographics_id']): ?><img src="<?php echo $this->baseUrl(); ?>/images/check_mark.png" alt="DONE"/><?php endif; ?> 
     </td> 
     <td class="center"> 
      <?php if($item['hp1'] && $item['hp2'] && $item['hp3'] && $item['hp4'] && $item['hp5'] && $item['hp6'] && $item['hp7'] && $item['hp8'] && $item['hp9'] && $item['hp10'] && $item['about1_id'] && $item['about2_id'] && $item['about3_id'] && $item['tip1_id'] && $item['tip2_id'] && $item['tip3_id'] && $item['contact_texts_id'] && $item['quote_texts_id']): ?><img src="<?php echo $this->baseUrl(); ?>/images/check_mark.png" alt="DONE"/><?php endif; ?> 
     </td> 
     <td class="center"> 
      <?php if(file_exists($_SERVER['DOCUMENT_ROOT'] . $this->baseUrl() . Zend_Registry::get('assets_base_path') . '/' . $item['id'] . '/header.jpg')): ?><img src="<?php echo $this->baseUrl(); ?>/images/check_mark.png" alt="DONE"/><?php endif; ?> 
     </td> 
     <td class="center"> 
      <?php 
       if(($item['bg_color'] != '' && $item['bg_color'] != 'e6e6e6') 
       || ($item['dark_color'] != '' && $item['dark_color'] != '003e75') 
       || ($item['light_color'] != '' && $item['light_color'] != '3073ad') 
       || ($item['links_color'] != '' && $item['links_color'] != '255593') 
       || ($item['text_color'] != '' && $item['text_color'] != '4f4f4f')): 
      ?> 
       <img src="<?php echo $this->baseUrl(); ?>/images/check_mark.png" alt="DONE"/> 
      <?php endif; ?> 
     </td> 
     <td class="center"> 
      <?php if($item['image1_id'] && $item['image2_id'] && $item['image3_id']): ?><img src="<?php echo $this->baseUrl(); ?>/images/check_mark.png" alt="DONE"/><?php endif; ?> 
     </td> 
     <td class="center"> 
      <?php if(!empty($item['twitter_user'])): ?><img src="<?php echo $this->baseUrl(); ?>/images/check_mark.png" alt="DONE"/><?php endif; ?> 
     </td> 
     <td class="center"> 
      <?php if(!empty($item['facebook_id'])): ?><img src="<?php echo $this->baseUrl(); ?>/images/check_mark.png" alt="DONE"/><?php endif; ?> 
     </td> 
     <td class="center"> 
      <?php if(!empty($item['phone_number'])): ?><img src="<?php echo $this->baseUrl(); ?>/images/check_mark.png" alt="DONE"/><?php endif; ?> 
     </td> 
     <td class="center"> 
      <?php if($item['google_account']): ?><img src="<?php echo $this->baseUrl(); ?>/images/check_mark.png" alt="DONE"/><?php endif; ?> 
     </td> 
     <td class="center"> 
      <?php if($item['video_made']): ?><img src="<?php echo $this->baseUrl(); ?>/images/check_mark.png" alt="DONE"/><?php endif; ?> 
     </td> 
     <td class="center"> 
      <?php if($item['youtube_position']) { echo $item['youtube_position']; }; ?> 
     </td> 
     <td class="center"> 
      <?php if(!empty($item['address'])): ?><img src="<?php echo $this->baseUrl(); ?>/images/check_mark.png" alt="DONE"/><?php endif; ?> 
     </td> 
     <td class="center"> 
      <?php if($item['gmaps_status'] == 1): ?><img src="<?php echo $this->baseUrl(); ?>/images/icon-gmapspending.png" alt="Pending"/><?php elseif($item['gmaps_status'] == 2): ?><img src="<?php echo $this->baseUrl(); ?>/images/check_mark.png" alt="DONE"/><?php endif; ?> 
     </td> 
     <td class="center"> 
      <?php if(!empty($item['ganalytics'])): ?><img src="<?php echo $this->baseUrl(); ?>/images/check_mark.png" alt="DONE"/><?php endif; ?> 
     </td> 
     <td class="center"> 
      <?php if($item['online']): ?><img src="<?php echo $this->baseUrl(); ?>/images/check_mark_red.png" alt="Online!"/><?php endif; ?> 
     </td> 
     <td class="center"> 
      <?php if($item['indexed']): ?><img src="<?php echo $this->baseUrl(); ?>/images/check_mark_red.png" alt="Online!"/><?php endif; ?> 
     </td> 
     <td class="center"> 
      <?php if($item['gmap_position']) { echo $item['gmap_position']; }; ?> 
     </td> 
     <td class="center"> 
      <?php if($item['google_position']) { echo $item['google_position']; }; ?> 
     </td> 
    </tr> 
<?php endforeach; ?> 
</table> 
<?php endif; ?> 

print_r (count ($ this-> paginator)); 라인은 "0"을 반환하고, $ this-> numOnline; 행은 1을 반환합니다. 따라서 데이터베이스의 웹 사이트 테이블에 행이 하나 있지만 웹 페이지의 행을 나열하고 페이지를 반환하지 않습니다. 이 원인을 일으키는 페이징 인이 0인지 또는 내가 모르는 다른 것을 반환하는지 확실하지 않습니다.

답변

1

잘 모르겠지만 조인 대신 joinLeft를 사용해보십시오. 아마도이 결과를내는 웹 사이트 테이블과 인구 통계 테이블 간의 관계 일 것입니다.

+0

정확히 그랬습니다. 감사. – Matto