table::model()->exists HowTo Question

Hi guys,

I’m still a little confused about the exists() Method…

I want to do the following query:


table::model()->exists(  Att1==1 AND Att2==3 AND Att3==5  )

Can anybody show me how to do it right?

THX

The method returns TRUE if a record with these conditions exist, otherwise it will return FALSE. Keep in mind that the condition parameter is actually an SQL statement. So you should only use one equals sign in your example. Like this:


$exists = table::model()->exists('Att1=1 AND Att2=3 AND Att3=5')

The $exists variable will now contain a boolean.

Table Exists, example:


Yii::app()->db->schema->getTable('{{users}}')