改名
This commit is contained in:
@@ -115,14 +115,14 @@ class ActiveRecord extends BaseActiveRecord
|
|||||||
*/
|
*/
|
||||||
public static function findOrCreate(array $condition, array $attributes = [])
|
public static function findOrCreate(array $condition, array $attributes = [])
|
||||||
{
|
{
|
||||||
$select = self::find()->where($condition)->first();
|
$select = static::find()->where($condition)->first();
|
||||||
if (!empty($select)) {
|
if (!empty($select)) {
|
||||||
return $select;
|
return $select;
|
||||||
}
|
}
|
||||||
if (empty($attributes)) {
|
if (empty($attributes)) {
|
||||||
return \logger()->addError(FIND_OR_CREATE_MESSAGE, 'mysql');
|
return \logger()->addError(FIND_OR_CREATE_MESSAGE, 'mysql');
|
||||||
}
|
}
|
||||||
$select = new self();
|
$select = new static();
|
||||||
$select->attributes = $attributes;
|
$select->attributes = $attributes;
|
||||||
if (!$select->save()) {
|
if (!$select->save()) {
|
||||||
throw new Exception($select->getLastError());
|
throw new Exception($select->getLastError());
|
||||||
|
|||||||
Reference in New Issue
Block a user