php - Yii $criteria->addBetweenCondition not Working in CDbCriteria

934

I want to get results of sender score between 1 to 10,So I have add this condtion.

   $criteria->addBetweenCondition('sender_score',$_GET['senderscore_start'],$_GET['senderscore_end']);

sender_score is my table field, senderscore_start and senderscore_end are only public variables.

My Search From Code:

<div >    
  <?php echo $form->label($model,'senderscore_start'); ?>
  <?php echo $form->textField($model,'senderscore_start',array('size'=>60,'maxlength'=>100,'style'=>'width:300px;')); ?>   
</div> 
<div >    
  <?php echo $form->label($model,'senderscore_end'); ?>
  <?php echo $form->textField($model,'senderscore_end',array('size'=>60,'maxlength'=>100,'style'=>'width:300px;')); ?>    
</div>

My Model Code:

public $senderscore_start;
public $senderscore_end;

array('senderscore_start,senderscore_end', 'safe', 'on'=>'search'),

$criteria->addBetweenCondition('sender_score',$_GET['senderscore_start'],$_GET['senderscore_end']);`

But not showing results between 1,10 , can you look at this please! what's wrong with my code. `

163

Answer

Solution:

You should not access any request variables like$_GET from inside your models. So the correct solution would be:

$criteria->addBetweenCondition('sender_score',$this->senderscore_start, $this->senderscore_end);
468

Answer

Solution:

Try this!

 $criteria->addBetweenCondition('sender_score',$_GET['IpManager']['senderscore_start'],$_GET['IpManager']['senderscore_end']);          

People are also looking for solutions to the problem: apache - How to properly increase PHP script execution time

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.