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