不要使用yii框架进行分页

时间:2014-04-08 07:17:16

标签: php yii

我是yii框架的新手。我正在做一个选择数据表单数据库,并用pagination.my控制器列出它是Sitecontroller.php,查看文件是search_result.php

控制器-Sitecontroller.php

 <?php
 class SiteController extends Controller
 {
 public function actionsearch_result()
  {
    $title=$_GET['title'];
    $experience=$_GET['experience'];
    $criteria=new CDbCriteria();
    $count=Job::model()->count($criteria);
    $pages=new CPagination($count);
    $pages->pageSize=2;
    $pages->applyLimit($criteria);
  $model=Job::model()->findAll(array('select'=>'*',
 "condition"=>"(title like     '%$title%')  
 or (key_skills like '%$title%')",));
  $this->render('search_result',array('model' =>$model,'title' =>$title,
  'experience'   =>$experience,'pages' => $pages));

  }

}    ?&GT;

查看-search_result.php

   <div style="float:right;margin-right:285px;">
   <h1>Search Results</h1>
   <ul style="list-style:none; ">
   <?php

foreach($model as $models)  
   { 
 $job_id=$models->id;
 ?>
  <li><p><?php echo $models->title; ?></p>

  <p><?php echo $models->company_name; ?></p>
  <p><?php echo $models->description; ?></p>
  <p>Keyskill:<?php echo $models->key_skills; ?><p>

  </li>
  <?php
   }
  ?>
</ul>    
  <p><?php $this->widget('CLinkPager', array(
     'pages' => $pages,
   )) ?></p>   

有人帮帮我吗?

1 个答案:

答案 0 :(得分:0)

使用CListView之类的this,强烈建议您阅读The Definitive Guide to YiiThe Yii Blog Tutorial