e
This commit is contained in:
+27
-1
@@ -13,9 +13,9 @@ namespace Database;
|
|||||||
use Database\Base\BaseActiveRecord;
|
use Database\Base\BaseActiveRecord;
|
||||||
use Database\Traits\HasBase;
|
use Database\Traits\HasBase;
|
||||||
use Exception;
|
use Exception;
|
||||||
use ReflectionException;
|
|
||||||
use Kiri\Exception\NotFindClassException;
|
use Kiri\Exception\NotFindClassException;
|
||||||
use Kiri\Kiri;
|
use Kiri\Kiri;
|
||||||
|
use ReflectionException;
|
||||||
|
|
||||||
defined('SAVE_FAIL') or define('SAVE_FAIL', 3227);
|
defined('SAVE_FAIL') or define('SAVE_FAIL', 3227);
|
||||||
defined('FIND_OR_CREATE_MESSAGE') or define('FIND_OR_CREATE_MESSAGE', 'Create a new model, but the data cannot be empty.');
|
defined('FIND_OR_CREATE_MESSAGE') or define('FIND_OR_CREATE_MESSAGE', 'Create a new model, but the data cannot be empty.');
|
||||||
@@ -241,6 +241,32 @@ class ActiveRecord extends BaseActiveRecord
|
|||||||
return $condition->batchUpdate($attributes);
|
return $condition->batchUpdate($attributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $condition
|
||||||
|
* @return ActiveRecord|null
|
||||||
|
* @throws NotFindClassException
|
||||||
|
* @throws ReflectionException
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static function first($condition): ?ActiveRecord
|
||||||
|
{
|
||||||
|
return static::query()->where($condition)->first();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $condition
|
||||||
|
* @return array|Collection
|
||||||
|
* @throws NotFindClassException
|
||||||
|
* @throws ReflectionException
|
||||||
|
*/
|
||||||
|
public static function get($condition): Collection|array
|
||||||
|
{
|
||||||
|
return static::query()->where($condition)->all();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $condition
|
* @param $condition
|
||||||
* @param array $attributes
|
* @param array $attributes
|
||||||
|
|||||||
Reference in New Issue
Block a user