DAO with yiinfinite-scroll

Dear All,

I am trying to use yiinfinite-scroll extension for my project and using DAO layer . Below is my code


 public function actionIndex(){

        $help=new Help();


        if($totalCount < 25)





 	$criteria = new CDbCriteria;

        $pages = new CPagination($totalCount);

        $pages->pageSize = $pageSize;


        $list= $help->listHelp($criteria->limit,$criteria->offset); 



DAO code

  public function listHelp($limit,$offset){   

        $connection = Yii::app()->db;       

        $sql='SELECT h.subject FROM tbl_help h WHERE LIMIT :limit OFFSET :offset ';

        $command = $connection->createCommand($sql); 





        $rowArray = $command->queryAll();        

        return $rowArray;          



  public function getHelpCount(){

    $sqlCount='SELECT COUNT(1) from tbl_help';


    return $count;



<?php $this->widget('ext.yiinfinite-scroll.YiinfiniteScroller', array(

			'contentSelector' => '#helps',

			'itemSelector' => 'div.help',

			'loadingText' => 'Loading...',

			'donetext' => '',

			'pages' => $pages,



<div id="helps">


 <?php foreach($helps as $help): ?>

    <div class="help">

        <p> <?php echo $help['subject']; ?></p>


<?php endforeach; ?> 



Issues Noticed

  1. If the page size is more than total records size , the records are displaying again and again … I mean if the page size is 25 and total records are 10 … then page displays 25 records that includes all the 10 records two times and then the first 5 records again . To avoid this I used below code

  if($totalCount < 25)




  1. In the above code I have to say $totalCount+0; some how the $totalCount coming as string from getHelpCount() method

  2. Even after displaying all the 10 records if I use the above condition to setup pagesize still I am seeing "Next" link to take me to the next page …where in fact no records exists …

Could some one let me know am I taking the right approach or am I missing some thing ?

Thanks for your help


Yii Fan