How To Display Columns In Cgridview Which Are Not Contained In Any Model?

I cannot display columns in cgridview which are not contained in any of the model’s virtual attribute


  

  fnname function is in model1 (wherein pid ,mid ,expirydate are the property) 


     ( fsp.pid = ".$this->pid." 

        AND fsp.mid=".$this->mid.

         )"; 

 

$this->pid is fk in model1 its belongs to model2 …$this->mid is pk to model1 the cgridview doesnt display for this code as the value for $this->pid $this->mid are null if i remove start to end it diplay the rest value




    public function  fnname()

	{

        $uid=Yii::app()->SESSION['mid'];

		$criteria=new CDbCriteria;

        //start

	    $post_table = Model1::model()->tableName();

    	$post_count_sql = "(SELECT  datediff(fsp.expirydate,CURDATE())as daysleft

        from $post_table fsp

        WHERE ( fsp.pid = ".$this->pid." 

        AND fsp.mid=".$this->mid.

         )";

		 

		$criteria->select = array(

        '*',

        $post_count_sql . " as daysleft",

    );

		

		$criteria->compare('$post_count_sql', $this->daysleft);

	    //end

		$criteria->condition='userid='.$userid;

	

		return new CActiveDataProvider($this, array(

			'criteria'=>$criteria,

			'pagination' => array('pageSize' => 2),

		));

	}

	

The error occurs




     SELECT  datediff(fsp.expirydate,CURDATE())as daysleft

         from tbl fsp

       WHERE ( fsp.pid = 

      AND fsp.mid=

     )



here fsp.pid and fsp.mid is blank

If i remove //start //end line, the gridview displays

if i have this query then




      (SELECT datediff( fsp.expirydate, CURDATE( ) ) AS daysleft

FROM tbl1 fsp


) 

     Cardinality violation: 1242 Subquery returns more than 1 row. The SQL statement executed was: SELECT *, (SELECT datediff( fsp.expirydate, CURDATE( ) ) AS daysleft

FROM tbl1 fsp


) as daysleft FROM `tbl1` `t` WHERE uid=3 



Please let me know what I am doing wrong. … am losing ma mind on this