diff --git a/src/models/AbstractRepository.php b/src/models/AbstractRepository.php new file mode 100644 index 00000000..bbc7f6a9 --- /dev/null +++ b/src/models/AbstractRepository.php @@ -0,0 +1,117 @@ +save($runValidation, $attributeNames); + } + + /** + * @param ActiveRecordInterface $model + * @param bool $runValidation + * @param null $attributeNames + * @return bool whether the attributes are valid and the record is inserted successfully. + */ + public function insert(ActiveRecordInterface $model, $runValidation = true, $attributeNames = null) + { + return $model->insert($runValidation, $attributeNames); + } + + /** + * @param ActiveRecordInterface $model + * @param bool $runValidation + * @param null $attributeNames + * @return int|bool the number of rows affected, or `false` if validation fails + * or updating process is stopped for other reasons. + * Note that it is possible that the number of rows affected is 0, even though the + * update execution is successful. + */ + public function update(ActiveRecordInterface $model, $runValidation = true, $attributeNames = null) + { + return $model->update($runValidation, $attributeNames); + } + + /** + * @param ActiveRecordInterface $model + * @return int|bool the number of rows deleted, or `false` if the deletion is unsuccessful for some reason. + * Note that it is possible that the number of rows deleted is 0, even though the deletion execution is successful. + */ + public function delete(ActiveRecordInterface $model) + { + return $model->delete(); + } +}