Yii Model Search, Cdbcriteria With Compare And Condition


i am currently trying to improve my search functionality by allowing users to find items added to the database between two dates i am doing this using the following code:

		$criteria=new CDbCriteria;

		$criteria->with = array( 'customer', 'userAssign');













		if(!empty($this->date_from) && !empty($this->date_to)){

		  $criteria->condition="`created` Between '$this->date_from' And '$this->date_to'";


Which is working fine but when a date_from and date_to is chosen on the search form other compare values entered are ignored such as is you choose a status. Am i right in thinking that you cannot mix cdbcriteria compare and condition? and if this is the case how else can this be achieved?

Thanks in advance

Ok so i have now changed it to this:

		if(!empty($this->date_from) && !empty($this->date_to)){

		  $criteria->addCondition("`created` Between '$this->date_from' And '$this->date_to'", 'AND');


Which seems to work ok…