Files
xk-api-yii/common/core/BaseNewActiveRecord.php

23 lines
553 B
PHP
Raw Normal View History

2024-12-19 19:20:27 +08:00
<?php
namespace common\core;
use yii\base\Exception;
use yii\db\ActiveRecord;
/**
* 对框架的AR的扩展所有前台/后台数据模型都继承自该类
*/
class BaseNewActiveRecord extends ActiveRecord
{
public static function getDb()
{
return \Yii::$app->get('new_db');
}
public function saveOrFail($runValidation = true, $attributeNames = null){
if(!$this->save($runValidation, $attributeNames)){
throw new Exception(implode(',',$this->getFirstErrors()));
}
return true;
}
}