Search functionality and pagenation

I have made a diff for the blog demo as follows.

http://code.google.c…rce/detail?r=19

This is actually for the blog-demo-enhanced, but I have confirmed that it can be applied to the original blog demo as well.

I have noticed that this patch has a bug, that is appeared where the number of the searched result exceeds the parameter of postsPerPage.

I know that the bug can be resolved when search string appears in the $_GET, because I do not have it in the $_POST on the second trial by clicking the next button of the pagenation.

Could someone please help me to resolve this bug?

It may be solved by the following code, which was not much diffcult that I had imagined though.

PostController.php



       public function actionSearch()


       {


               $search=new SiteSearchForm;


               if(isset($_POST['SiteSearchForm'])) {


+                       $search->attributes=$_POST['SiteSearchForm'];


+                       $_GET['searchString'] = $search->string;


+ 


+               } else {


+                       $search->attributes=$_GET['searchString'];


+               }


 


               $criteria=new CDbCriteria;


               $criteria->condition='status='.Post::STATUS_PUBLISHED;


               $criteria->condition.=' AND content like '%'.$search->string.'%'';


               $criteria->order='createTime DESC';


It may be a tip for the combination of the searching and pagenation.

The code was incomplete. And I think I was able to fix this bug and eliminated the risk of SQL injection according to Qiang's suggestion. You can see the diff at the google code, but I can show the code central for your reference.

http://code.google.c…rce/detail?r=20

protected/controllers/PostController.php:

You can see the demo here.