dr6673999
dr6673999
2013-09-25 07:58

如何使用基于sql查询的单选按钮过滤gridview

已采纳

I'm using two radiobuttons in advanced search form, they are approved and rejected. When I click on approved it should filter for multiple search box in Gridview and display the result. There are other three fields 'Updated date','reviewed date' and 'created date' also. Suppose, I click on the approved button. It should check for the condition updated time is greater than created date and reviewed date is NOT NULL and display the results.

SQL query-Select * from test where (updateddate>createddate)and(revieweddate!=NULL) and approved=1

For rejected, the same needs to be done with approved=0 I have done the following to radiobuttons in advanced search form.

<div class="row"> 
<?php echo $form->radioButtonList($model, 'Approved', 
        array('0' => 'Rejected', '1' => 'Approved')
    ); ?> 
</div> 

How can I get the values of all the rows which satisfy the above criteria.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答

  • droxy80248 droxy80248 8年前

    You can use "$criteria->condition" like this:

    $criteria->condition = ' (updateddate > createddate) AND (revieweddate IS NOT NULL) and approved = 1 ';
    
    点赞 评论 复制链接分享

相关推荐