Files
xk-api-yii/common/core/BaseActiveRecord.php
2024-09-19 11:32:39 +08:00

19 lines
461 B
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?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;
}
}