Check Existance Of Entry In Model Within View File

This might sound kind of basic (and it probably is) but I’ve been trying to get this for a few hours now and either I need a break from coding or it just wont budge.

I have an active record variable which brings database entries from a model:

$variable = Model::model()->findAll();

So I have $variable available in my view file and I want to check for the existance of a specific entry within the results. I am using the primary key of an entry available in the $variable but I can’t seem to get it working.

What is the correct way to check if a given entry is contained within that variable from the view file, not the controller?

PS: I do not want to iterate through the result set, it wouldn’t be very efficient for my application.


there is a instance method on ActiveRecord exists() method to check if a record exists or not

 MODELNAME::model()->exists( array( your conditions in case you any) ); 

Yeah I had tried that. It works in the controller, but it does not work in the view file for some reason.