1 | <?php |
||
46 | class ActiveRecord extends BaseActiveRecord |
||
47 | { |
||
|
|||
48 | /** |
||
49 | * Returns the LDAP connection used by this AR class. |
||
50 | * |
||
51 | * @return Connection the LDAP connection used by this AR class. |
||
52 | */ |
||
53 | public static function getDb() |
||
57 | |||
58 | /** |
||
59 | * @inheritdoc |
||
60 | * @return ActiveQuery the newly created [[ActiveQuery]] instance. |
||
61 | */ |
||
62 | public static function find() |
||
66 | |||
67 | /** |
||
68 | * Returns the primary key name(s) for this AR class. |
||
69 | * This method should be overridden by child classes to define the primary key. |
||
70 | * |
||
71 | * @return string[] the primary keys of this record. |
||
72 | */ |
||
73 | public static function primaryKey() |
||
77 | |||
78 | /** |
||
79 | * Returns the list of attribute names. |
||
80 | * You must override this method to define avaliable attributes. |
||
81 | * @return array list of attribute names. |
||
82 | */ |
||
83 | public function attributes() |
||
87 | |||
88 | /** |
||
89 | * Inserts a row into the associated database table using the attribute values of this record. |
||
90 | * |
||
91 | * This method performs the following steps in order: |
||
92 | * |
||
93 | * 1. call [[beforeValidate()]] when `$runValidation` is true. If [[beforeValidate()]] |
||
94 | * returns `false`, the rest of the steps will be skipped; |
||
95 | * 2. call [[afterValidate()]] when `$runValidation` is true. If validation |
||
96 | * failed, the rest of the steps will be skipped; |
||
97 | * 3. call [[beforeSave()]]. If [[beforeSave()]] returns `false`, |
||
98 | * the rest of the steps will be skipped; |
||
99 | * 4. insert the record into database. If this fails, it will skip the rest of the steps; |
||
100 | * 5. call [[afterSave()]]; |
||
101 | * |
||
102 | * In the above step 1, 2, 3 and 5, events [[EVENT_BEFORE_VALIDATE]], |
||
103 | * [[EVENT_AFTER_VALIDATE]], [[EVENT_BEFORE_INSERT]], and [[EVENT_AFTER_INSERT]] |
||
104 | * will be raised by the corresponding methods. |
||
105 | * |
||
106 | * Only the [[dirtyAttributes|changed attribute values]] will be inserted into database. |
||
107 | * |
||
108 | * If the table's primary key is auto-incremental and is null during insertion, |
||
109 | * it will be populated with the actual value after insertion. |
||
110 | * |
||
111 | * For example, to insert a customer record: |
||
112 | * |
||
113 | * ```php |
||
114 | * $customer = new Customer; |
||
115 | * $customer->name = $name; |
||
116 | * $customer->email = $email; |
||
117 | * $customer->insert(); |
||
118 | * ``` |
||
119 | * |
||
120 | * @param boolean $runValidation whether to perform validation (calling [[validate()]]) |
||
121 | * before saving the record. Defaults to `true`. If the validation fails, the record |
||
122 | * will not be saved to the database and this method will return `false`. |
||
123 | * @param string[]|null $attributes list of attributes that need to be saved. Defaults to null, meaning all attributes that are loaded from DB will be saved. meaning all attributes that are loaded from DB will be saved. |
||
124 | * meaning all attributes that are loaded from DB will be saved. |
||
125 | * @return boolean whether the attributes are valid and the record is inserted successfully. |
||
126 | * @throws Exception in case insert failed. |
||
127 | */ |
||
128 | public function insert($runValidation = true, $attributes = null) |
||
137 | |||
138 | /** |
||
139 | * Inserts an ActiveRecord into LDAP without. |
||
140 | * |
||
141 | * @param string[]|null $attributes list of attributes that need to be saved. Defaults to null, |
||
142 | * meaning all attributes that are loaded will be saved. |
||
143 | * @return boolean whether the record is inserted successfully. |
||
144 | */ |
||
145 | protected function insertInternal($attributes = null) |
||
172 | |||
173 | /** |
||
174 | * @see update() |
||
175 | * @param array $attributes attributes to update |
||
176 | * @return integer number of rows updated |
||
177 | * @throws StaleObjectException |
||
178 | */ |
||
179 | protected function updateInternal($attributes = null) |
||
232 | |||
233 | /** |
||
234 | * Updates the whole table using the provided attribute values and conditions. |
||
235 | * For example, to change the status to be 1 for all customers whose status is 2: |
||
236 | * |
||
237 | * ```php |
||
238 | * Customer::updateAll(['status' => 1], 'status = 2'); |
||
239 | * ``` |
||
240 | * |
||
241 | * @param array $attributes attribute values (name-value pairs) to be saved into the table |
||
242 | * @param string|array $condition the conditions that will be put in the WHERE part of the UPDATE SQL. |
||
243 | * Please refer to [[Query::where()]] on how to specify this parameter. |
||
244 | * @return integer the number of rows updated |
||
245 | */ |
||
246 | public static function updateAll($attributes, $condition = '') |
||
258 | |||
259 | /** |
||
260 | * Deletes rows in the table using the provided conditions. |
||
261 | * WARNING: If you do not specify any condition, this method will delete ALL rows in the ldap directory. |
||
262 | * |
||
263 | * For example, to delete all customers whose status is 3: |
||
264 | * |
||
265 | * ```php |
||
266 | * Customer::deleteAll('status = 3'); |
||
267 | * ``` |
||
268 | * |
||
269 | * @param string|array $condition the conditions that will be put in the WHERE part of the DELETE SQL. |
||
270 | * Please refer to [[Query::where()]] on how to specify this parameter. |
||
271 | * @return integer the number of rows deleted |
||
272 | */ |
||
273 | public static function deleteAll($condition = '') |
||
287 | } |
||
288 |