UserMetadata::model()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
/**
4
 * This is the model class for table "user_metadata".
5
 *
6
 * The followings are the available columns in table 'user_metadata':
7
 * @property integer $id
8
 * @property integer $user_id
9
 * @property string $key
10
 * @property string $value
11
 * @property string $created
12
 * @property string $updated
13
 *
14
 * The followings are the available model relations:
15
 * @property Users $user
16
 */
17
class UserMetadata extends CiiModel
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
18
{
19
	/**
20
	 * Returns the static model of the specified AR class.
21
	 * @param string $className active record class name.
22
	 * @return UserMetadata the static model class
23
	 */
24
	public static function model($className=__CLASS__)
25
	{
26
		return parent::model($className);
27
	}
28
29
	/**
30
	 * @return string the associated database table name
31
	 */
32
	public function tableName()
33
	{
34
		return 'user_metadata';
35
	}
36
37
	/**
38
	 * @return array validation rules for model attributes.
39
	 */
40
	public function rules()
41
	{
42
		// NOTE: you should only define rules for those attributes that
43
		// will receive user inputs.
44
		return array(
45
			array('user_id, key, value', 'required'),
46
			array('user_id, entity_type', 'numerical', 'integerOnly'=>true),
47
			array('key', 'length', 'max'=>50),
48
			// The following rule is used by search().
49
			array('id, user_id, key, value, entity_type, created, updated', 'safe', 'on'=>'search'),
50
		);
51
	}
52
53
	/**
54
	 * @return array relational rules.
55
	 */
56
	public function relations()
57
	{
58
		// NOTE: you may need to adjust the relation name and the related
59
		// class name for the relations automatically generated below.
60
		return array(
61
			'user' => array(self::BELONGS_TO, 'Users', 'user_id'),
62
		);
63
	}
64
65
	/**
66
	 * @return array customized attribute labels (name=>label)
67
	 */
68
	public function attributeLabels()
69
	{
70
		return array(
71
			'id' 		  => Yii::t('ciims.models.UserMetadata', 'ID'),
72
			'user_id' 	  => Yii::t('ciims.models.UserMetadata', 'User'),
73
			'key' 		  => Yii::t('ciims.models.UserMetadata', 'Key'),
74
			'value' 	  => Yii::t('ciims.models.UserMetadata', 'Value'),
75
			'entity_type' => Yii::t('ciims.models.UserMetadata', 'Entity Type'),
76
			'created' 	  => Yii::t('ciims.models.UserMetadata', 'Created'),
77
			'updated'     => Yii::t('ciims.models.UserMetadata', 'Updated'),
78
		);
79
	}
80
81
	/**
82
	 * Retrieves a list of models based on the current search/filter conditions.
83
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
84
	 */
85
	public function search()
86
	{
87
		$criteria=new CDbCriteria;
88
89
		$criteria->compare('id',$this->id);
90
		$criteria->compare('user_id',$this->user_id);
91
		$criteria->compare('key',$this->key,true);
92
		$criteria->compare('value',$this->value,true);
93
		$criteria->compare('entity_type',$this->entity_type,true);
94
		$criteria->compare('created',$this->created,true);
95
		$criteria->compare('updated',$this->updated,true);
96
97
		return new CActiveDataProvider($this, array(
98
			'criteria'=>$criteria,
99
		));
100
	}
101
}
102