1 : <?php
2 :
3 :
4 :
5 :
6 :
7 :
8 :
9 :
10 :
11 :
12 :
13 :
14 :
15 : class BasicAR extends CActiveRecord {
16 :
17 :
18 :
19 :
20 : public static function model($className=__CLASS__) {
21 0 : return parent::model($className);
22 : }
23 :
24 :
25 :
26 :
27 : public function tableName() {
28 6 : return 'tbl_basic_ar';
29 : }
30 :
31 :
32 :
33 :
34 : public function rules() {
35 : return array(
36 :
37 : array (
38 6 : 'column_number, column_range, column_regex, column_string',
39 6 : 'required',
40 6 : ),
41 :
42 :
43 : array (
44 6 : 'column_boolean, column_number, column_range',
45 6 : 'numerical',
46 6 : 'integerOnly' => true,
47 6 : ),
48 :
49 : array (
50 6 : 'column_boolean',
51 6 : 'boolean',
52 6 : ),
53 :
54 : array (
55 6 : 'column_number',
56 6 : 'numerical',
57 6 : 'min' => 1,
58 6 : 'max' => 10,
59 6 : ),
60 :
61 : array (
62 6 : 'column_range',
63 6 : 'in',
64 6 : 'range' => array (1,3,5,7,9),
65 6 : ),
66 :
67 :
68 : array (
69 6 : 'column_regex, column_safe',
70 6 : 'length',
71 6 : 'max' => 255,
72 6 : ),
73 :
74 :
75 : array (
76 6 : 'column_string',
77 6 : 'length',
78 6 : 'max' => 15,
79 6 : ),
80 :
81 : array (
82 6 : 'column_regex',
83 6 : 'match',
84 6 : 'pattern' => '/\w+ \d+/',
85 6 : 'message' => '{attribute} must contain a word, a space then a number.',
86 6 : ),
87 :
88 :
89 :
90 :
91 : array (
92 6 : 'id, column_boolean, column_number, column_range, column_regex, column_string, column_safe',
93 6 : 'safe',
94 6 : 'on' => 'search',
95 6 : ),
96 6 : );
97 : }
98 :
99 :
100 :
101 :
102 : public function attributeLabels() {
103 : return array(
104 2 : 'id' => 'ID',
105 2 : 'column_boolean' => 'Boolean',
106 2 : 'column_number' => 'Number',
107 2 : 'column_range' => 'Range',
108 2 : 'column_regex' => 'Regexp',
109 2 : 'column_string' => 'String',
110 2 : 'column_safe' => 'Safe',
111 2 : );
112 : }
113 :
114 :
115 :
116 :
117 :
118 : public function search() {
119 3 : $criteria=new CDbCriteria;
120 3 : $criteria->compare ('id', $this->id);
121 3 : $criteria->compare ('column_boolean', $this->column_boolean);
122 3 : $criteria->compare ('column_number', $this->column_number);
123 3 : $criteria->compare ('column_range', $this->column_range);
124 3 : $criteria->compare ('column_regex', $this->column_regex, true);
125 3 : $criteria->compare ('column_string', $this->column_string, true);
126 3 : $criteria->compare ('column_safe', $this->column_safe, true);
127 :
128 3 : return new CActiveDataProvider('BasicAR', array(
129 3 : 'criteria' => $criteria,
130 3 : ));
131 : }
132 : }
|