初始化仓库
This commit is contained in:
18
common/core/BaseActiveRecord.php
Normal file
18
common/core/BaseActiveRecord.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
namespace common\core;
|
||||
|
||||
use yii\base\Exception;
|
||||
use yii\db\ActiveRecord;
|
||||
|
||||
/**
|
||||
* 对框架的AR的扩展,所有前台/后台数据模型都继承自该类
|
||||
*/
|
||||
class BaseActiveRecord extends ActiveRecord
|
||||
{
|
||||
public function saveOrFail($runValidation = true, $attributeNames = null){
|
||||
if(!$this->save($runValidation, $attributeNames)){
|
||||
throw new Exception(implode(',',$this->getFirstErrors()));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user