1 <?php
2
3 namespace Docoflow\Models;
4
5 use Yii;
6 use CDbCriteria;
7 use CActiveRecord;
8 use CActiveDataProvider;
9
10 /**
11 * This is the model class for table "workflow_state".
12 *
13 * The followings are the available columns in table 'workflow_state':
14 *
15 * @property int $id
16 * @property string $name
17 */
18 class WorkflowState extends CActiveRecord
19 {
20 /**
21 * Get DB Connection
22 *
23 * @return \CDbConnection
24 */
25 public function getDbConnection()
26 {
27 Yii::app()->container->bindIf('docoflow.connection', function ($container) {
28 return Yii::app()->db;
29 });
30
31 return Yii::app()->container->make('docoflow.connection');
32 }
33
34 /**
35 * Returns the static model of the specified AR class.
36 *
37 * @param string $className active record class name.
38 *
39 * @return WorkflowState the static model class
40 */
41 public static function model($className = __CLASS__)
42 {
43 return parent::model($className);
44 }
45
46 /**
47 * @return string the associated database table name
48 */
49 public function tableName()
50 {
51 return '"workflow_state"';
52 }
53
54 /**
55 * @return array validation rules for model attributes.
56 */
57 public function rules()
58 {
59 // NOTE: you should only define rules for those attributes that
60 // will receive user inputs.
61 return array(
62 array('name', 'length', 'max' => 512),
63 // The following rule is used by search().
64 // Please remove those attributes that should not be searched.
65 array('id, name', 'safe', 'on' => 'search'),
66 );
67 }
68
69 /**
70 * @return array relational rules.
71 */
72 public function relations()
73 {
74 // NOTE: you may need to adjust the relation name and the related
75 // class name for the relations automatically generated below.
76 return array(
77 );
78 }
79
80 /**
81 * @return array customized attribute labels (name=>label)
82 */
83 public function attributeLabels()
84 {
85 return array(
86 'id' => 'ID',
87 'name' => 'Name',
88 );
89 }
90
91 /**
92 * Retrieves a list of models based on the current search/filter conditions.
93 *
94 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
95 */
96 public function search()
97 {
98 // Warning: Please modify the following code to remove attributes that
99 // should not be searched.
100
101 $criteria = new CDbCriteria();
102
103 $criteria->compare('"id"', $this->id);
104 $criteria->compare('"name"', $this->name, true);
105
106 return new CActiveDataProvider($this, array(
107 'criteria' => $criteria,
108 ));
109 }
110 }
111