model() public static method

Returns the static model of the specified AR class.
public static model ( $className = __CLASS__ ) : ContactMetadata
return ContactMetadata the static model class
Example #1
0
 public function setMetadata($key, $value)
 {
     if (!($cm = ContactMetadata::model()->find('contact_id=? and `key`=?', array($this->owner->contact_id, $key)))) {
         $cm = new ContactMetadata();
         $cm->contact_id = $this->owner->contact_id;
         $cm->key = $key;
     }
     $cm->value = $value;
     if (!$cm->save()) {
         throw new Exception('Unable to save contact metadata: ' . print_r($cm->getErrors(), true));
     }
 }
 /**
  * @covers ContactMetadata::model
  */
 public function testModel()
 {
     $this->assertEquals('ContactMetadata', get_class(ContactMetadata::model()), 'Class name should match model.');
 }