modify
This commit is contained in:
@@ -11,7 +11,7 @@ namespace Database;
|
||||
|
||||
use Database\Traits\QueryTrait;
|
||||
use Exception;
|
||||
use Snowflake\Abstracts\Component;
|
||||
use Kiri\Abstracts\Component;
|
||||
|
||||
/**
|
||||
* Class ActiveQuery
|
||||
|
||||
@@ -14,8 +14,8 @@ use Database\Base\BaseActiveRecord;
|
||||
use Database\Traits\HasBase;
|
||||
use Exception;
|
||||
use ReflectionException;
|
||||
use Snowflake\Exception\NotFindClassException;
|
||||
use Snowflake\Snowflake;
|
||||
use Kiri\Exception\NotFindClassException;
|
||||
use Kiri\Kiri;
|
||||
|
||||
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.');
|
||||
@@ -115,7 +115,7 @@ class ActiveRecord extends BaseActiveRecord
|
||||
*/
|
||||
public static function findOrCreate(array $condition, array $attributes = []): bool|static
|
||||
{
|
||||
$logger = Snowflake::app()->getLogger();
|
||||
$logger = Kiri::app()->getLogger();
|
||||
|
||||
/** @var static $select */
|
||||
$select = static::find()->where($condition)->first();
|
||||
@@ -142,7 +142,7 @@ class ActiveRecord extends BaseActiveRecord
|
||||
*/
|
||||
public static function createOrUpdate(array $condition, array $attributes = []): bool|static
|
||||
{
|
||||
$logger = Snowflake::app()->getLogger();
|
||||
$logger = Kiri::app()->getLogger();
|
||||
if (empty($attributes)) {
|
||||
return $logger->addError(FIND_OR_CREATE_MESSAGE, 'mysql');
|
||||
}
|
||||
@@ -200,7 +200,7 @@ class ActiveRecord extends BaseActiveRecord
|
||||
public static function inserts(array $data): bool
|
||||
{
|
||||
/** @var static $class */
|
||||
$class = Snowflake::createObject(['class' => static::class]);
|
||||
$class = Kiri::createObject(['class' => static::class]);
|
||||
if (empty($data)) {
|
||||
return $class->addError('Insert data empty.', 'mysql');
|
||||
}
|
||||
@@ -288,7 +288,7 @@ class ActiveRecord extends BaseActiveRecord
|
||||
{
|
||||
$data = $this->_attributes;
|
||||
|
||||
$lists = Snowflake::getAnnotation()->getGets(static::class);
|
||||
$lists = Kiri::getAnnotation()->getGets(static::class);
|
||||
foreach ($lists as $key => $item) {
|
||||
$data[$key] = $this->{$item}($data[$key] ?? null);
|
||||
}
|
||||
|
||||
@@ -15,8 +15,8 @@ use Database\ActiveQuery;
|
||||
use Database\ActiveRecord;
|
||||
use Exception;
|
||||
use JetBrains\PhpStorm\Pure;
|
||||
use Snowflake\Abstracts\Component;
|
||||
use Snowflake\Snowflake;
|
||||
use Kiri\Abstracts\Component;
|
||||
use Kiri\Kiri;
|
||||
use Traversable;
|
||||
|
||||
/**
|
||||
|
||||
@@ -26,20 +26,20 @@ use Database\Traits\HasBase;
|
||||
use Exception;
|
||||
use JetBrains\PhpStorm\Pure;
|
||||
use ReflectionException;
|
||||
use Snowflake\Abstracts\Component;
|
||||
use Snowflake\Abstracts\Config;
|
||||
use Snowflake\Abstracts\TraitApplication;
|
||||
use Snowflake\Application;
|
||||
use Snowflake\Events\EventDispatch;
|
||||
use Snowflake\Exception\ConfigException;
|
||||
use Snowflake\Exception\NotFindClassException;
|
||||
use Snowflake\Snowflake;
|
||||
use Kiri\Abstracts\Component;
|
||||
use Kiri\Abstracts\Config;
|
||||
use Kiri\Abstracts\TraitApplication;
|
||||
use Kiri\Application;
|
||||
use Kiri\Events\EventDispatch;
|
||||
use Kiri\Exception\ConfigException;
|
||||
use Kiri\Exception\NotFindClassException;
|
||||
use Kiri\Kiri;
|
||||
use validator\Validator;
|
||||
|
||||
/**
|
||||
* Class BOrm
|
||||
*
|
||||
* @package Snowflake\Abstracts
|
||||
* @package Kiri\Abstracts
|
||||
*
|
||||
* @property bool $isCreate
|
||||
* @method rules()
|
||||
@@ -114,7 +114,7 @@ abstract class BaseActiveRecord extends Component implements IOrm, ArrayAccess
|
||||
*/
|
||||
#[Pure] protected function getContainer(): Application
|
||||
{
|
||||
return Snowflake::app();
|
||||
return Kiri::app();
|
||||
}
|
||||
|
||||
|
||||
@@ -125,7 +125,7 @@ abstract class BaseActiveRecord extends Component implements IOrm, ArrayAccess
|
||||
*/
|
||||
protected function getEventDispatch(): EventDispatch
|
||||
{
|
||||
return Snowflake::getDi()->get(EventDispatch::class);
|
||||
return Kiri::getDi()->get(EventDispatch::class);
|
||||
}
|
||||
|
||||
|
||||
@@ -176,7 +176,7 @@ abstract class BaseActiveRecord extends Component implements IOrm, ArrayAccess
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
$an = Snowflake::app()->getAnnotation();
|
||||
$an = Kiri::app()->getAnnotation();
|
||||
$an->injectProperty($this);
|
||||
}
|
||||
|
||||
@@ -216,7 +216,7 @@ abstract class BaseActiveRecord extends Component implements IOrm, ArrayAccess
|
||||
*/
|
||||
public function getLastError(): mixed
|
||||
{
|
||||
return Snowflake::app()->getLogger()->getLastError('mysql');
|
||||
return Kiri::app()->getLogger()->getLastError('mysql');
|
||||
}
|
||||
|
||||
|
||||
@@ -705,7 +705,7 @@ abstract class BaseActiveRecord extends Component implements IOrm, ArrayAccess
|
||||
*/
|
||||
public function getRelate($name): null|array|string
|
||||
{
|
||||
return Snowflake::getAnnotation()->getRelateMethods(static::class, $name);
|
||||
return Kiri::getAnnotation()->getRelateMethods(static::class, $name);
|
||||
}
|
||||
|
||||
|
||||
@@ -811,7 +811,7 @@ abstract class BaseActiveRecord extends Component implements IOrm, ArrayAccess
|
||||
*/
|
||||
protected function _get_annotation(string $name = null, string $method = self::GET): ?string
|
||||
{
|
||||
$annotation = Snowflake::app()->getAnnotation();
|
||||
$annotation = Kiri::app()->getAnnotation();
|
||||
if ($method == static::SET) {
|
||||
return $annotation->getSetMethodName(static::class, $name);
|
||||
}
|
||||
@@ -1032,7 +1032,7 @@ abstract class BaseActiveRecord extends Component implements IOrm, ArrayAccess
|
||||
*/
|
||||
public static function setDatabaseConnect($dbName): Connection
|
||||
{
|
||||
return Snowflake::app()->db->get(static::$connection = $dbName);
|
||||
return Kiri::app()->db->get(static::$connection = $dbName);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -13,8 +13,8 @@ namespace Database;
|
||||
use Exception;
|
||||
use PDO;
|
||||
use PDOStatement;
|
||||
use Snowflake\Abstracts\Component;
|
||||
use Snowflake\Core\Json;
|
||||
use Kiri\Abstracts\Component;
|
||||
use Kiri\Core\Json;
|
||||
|
||||
/**
|
||||
* Class Command
|
||||
|
||||
@@ -5,8 +5,8 @@ namespace Database\Condition;
|
||||
|
||||
|
||||
use JetBrains\PhpStorm\Pure;
|
||||
use Snowflake\Abstracts\BaseObject;
|
||||
use Snowflake\Core\Str;
|
||||
use Kiri\Abstracts\BaseObject;
|
||||
use Kiri\Core\Str;
|
||||
|
||||
/**
|
||||
* Class Condition
|
||||
|
||||
@@ -3,7 +3,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Database\Condition;
|
||||
|
||||
use Snowflake\Core\Str;
|
||||
use Kiri\Core\Str;
|
||||
|
||||
/**
|
||||
* Class LLikeCondition
|
||||
|
||||
@@ -3,7 +3,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Database\Condition;
|
||||
|
||||
use Snowflake\Core\Str;
|
||||
use Kiri\Core\Str;
|
||||
|
||||
/**
|
||||
* Class LikeCondition
|
||||
|
||||
@@ -3,7 +3,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Database\Condition;
|
||||
|
||||
use Snowflake\Core\Str;
|
||||
use Kiri\Core\Str;
|
||||
|
||||
/**
|
||||
* Class NotLikeCondition
|
||||
|
||||
@@ -3,7 +3,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Database\Condition;
|
||||
|
||||
use Snowflake\Core\Str;
|
||||
use Kiri\Core\Str;
|
||||
|
||||
/**
|
||||
* Class RLikeCondition
|
||||
|
||||
+12
-12
@@ -22,12 +22,12 @@ use PDO;
|
||||
use ReflectionException;
|
||||
use Server\Events\OnWorkerExit;
|
||||
use Server\Events\OnWorkerStop;
|
||||
use Snowflake\Abstracts\Component;
|
||||
use Snowflake\Abstracts\Config;
|
||||
use Snowflake\Event;
|
||||
use Snowflake\Events\EventProvider;
|
||||
use Snowflake\Exception\NotFindClassException;
|
||||
use Snowflake\Snowflake;
|
||||
use Kiri\Abstracts\Component;
|
||||
use Kiri\Abstracts\Config;
|
||||
use Kiri\Event;
|
||||
use Kiri\Events\EventProvider;
|
||||
use Kiri\Exception\NotFindClassException;
|
||||
use Kiri\Kiri;
|
||||
|
||||
/**
|
||||
* Class Connection
|
||||
@@ -146,7 +146,7 @@ class Connection extends Component
|
||||
public function getSchema(): Schema
|
||||
{
|
||||
if ($this->_schema === null) {
|
||||
$this->_schema = Snowflake::createObject([
|
||||
$this->_schema = Kiri::createObject([
|
||||
'class' => Schema::class,
|
||||
'db' => $this
|
||||
]);
|
||||
@@ -176,7 +176,7 @@ class Connection extends Component
|
||||
if (!$this->enableCache) {
|
||||
return null;
|
||||
}
|
||||
return Snowflake::app()->get($this->cacheDriver);
|
||||
return Kiri::app()->get($this->cacheDriver);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -210,12 +210,12 @@ class Connection extends Component
|
||||
|
||||
|
||||
/**
|
||||
* @return \Snowflake\Pool\Connection
|
||||
* @return \Kiri\Pool\Connection
|
||||
* @throws Exception
|
||||
*/
|
||||
private function connections(): \Snowflake\Pool\Connection
|
||||
private function connections(): \Kiri\Pool\Connection
|
||||
{
|
||||
return Snowflake::getDi()->get(\Snowflake\Pool\Connection::class);
|
||||
return Kiri::getDi()->get(\Kiri\Pool\Connection::class);
|
||||
}
|
||||
|
||||
|
||||
@@ -293,7 +293,7 @@ class Connection extends Component
|
||||
*/
|
||||
public function release()
|
||||
{
|
||||
if (!Snowflake::isWorker() && !Snowflake::isProcess()) {
|
||||
if (!Kiri::isWorker() && !Kiri::isProcess()) {
|
||||
$this->clear_connection();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -7,12 +7,12 @@ namespace Database;
|
||||
use Annotation\Inject;
|
||||
use Exception;
|
||||
use Server\Events\OnWorkerStart;
|
||||
use Snowflake\Abstracts\Config;
|
||||
use Snowflake\Abstracts\Providers;
|
||||
use Snowflake\Application;
|
||||
use Snowflake\Events\EventProvider;
|
||||
use Snowflake\Exception\ConfigException;
|
||||
use Snowflake\Snowflake;
|
||||
use Kiri\Abstracts\Config;
|
||||
use Kiri\Abstracts\Providers;
|
||||
use Kiri\Application;
|
||||
use Kiri\Events\EventProvider;
|
||||
use Kiri\Exception\ConfigException;
|
||||
use Kiri\Kiri;
|
||||
|
||||
/**
|
||||
* Class DatabasesProviders
|
||||
@@ -53,7 +53,7 @@ class DatabasesProviders extends Providers
|
||||
*/
|
||||
public function get($name): Connection
|
||||
{
|
||||
$application = Snowflake::app();
|
||||
$application = Kiri::app();
|
||||
if (!$application->has('databases.' . $name)) {
|
||||
$application->set('databases.' . $name, $this->_settings($this->getConfig($name)));
|
||||
}
|
||||
@@ -71,7 +71,7 @@ class DatabasesProviders extends Providers
|
||||
if (empty($databases)) {
|
||||
return;
|
||||
}
|
||||
$application = Snowflake::app();
|
||||
$application = Kiri::app();
|
||||
foreach ($databases as $name => $database) {
|
||||
/** @var Connection $connection */
|
||||
$application->set('databases.' . $name, $this->_settings($database));
|
||||
|
||||
+3
-3
@@ -14,9 +14,9 @@ use Database\Affair\Commit;
|
||||
use Database\Affair\Rollback;
|
||||
use Database\Traits\QueryTrait;
|
||||
use Exception;
|
||||
use Snowflake\Abstracts\Config;
|
||||
use Snowflake\Events\EventDispatch;
|
||||
use Snowflake\Exception\ConfigException;
|
||||
use Kiri\Abstracts\Config;
|
||||
use Kiri\Events\EventDispatch;
|
||||
use Kiri\Exception\ConfigException;
|
||||
|
||||
/**
|
||||
* Class Db
|
||||
|
||||
@@ -15,8 +15,8 @@ use Database\Connection;
|
||||
use Database\SqlBuilder;
|
||||
use Exception;
|
||||
use JetBrains\PhpStorm\Pure;
|
||||
use Snowflake\Abstracts\Component;
|
||||
use Snowflake\Core\Json;
|
||||
use Kiri\Abstracts\Component;
|
||||
use Kiri\Core\Json;
|
||||
|
||||
/**
|
||||
* Class Columns
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace Database\Mysql;
|
||||
|
||||
|
||||
use Exception;
|
||||
use Snowflake\Abstracts\Component;
|
||||
use Kiri\Abstracts\Component;
|
||||
use Database\Connection;
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace Database;
|
||||
|
||||
use Closure;
|
||||
use Exception;
|
||||
use Snowflake\Abstracts\Component;
|
||||
use Kiri\Abstracts\Component;
|
||||
|
||||
/**
|
||||
* Class Pagination
|
||||
|
||||
@@ -5,11 +5,11 @@ namespace Database;
|
||||
|
||||
|
||||
use Exception;
|
||||
use Snowflake\Abstracts\Component;
|
||||
use Kiri\Abstracts\Component;
|
||||
|
||||
/**
|
||||
* Class Relation
|
||||
* @package Snowflake\db
|
||||
* @package Kiri\db
|
||||
*/
|
||||
class Relation extends Component
|
||||
{
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace Database;
|
||||
use Database\Traits\Builder;
|
||||
use Exception;
|
||||
use JetBrains\PhpStorm\Pure;
|
||||
use Snowflake\Abstracts\Component;
|
||||
use Kiri\Abstracts\Component;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -13,8 +13,8 @@ use Database\SqlBuilder;
|
||||
use Exception;
|
||||
use JetBrains\PhpStorm\Pure;
|
||||
use ReflectionException;
|
||||
use Snowflake\Exception\NotFindClassException;
|
||||
use Snowflake\Snowflake;
|
||||
use Kiri\Exception\NotFindClassException;
|
||||
use Kiri\Kiri;
|
||||
|
||||
|
||||
/**
|
||||
@@ -181,13 +181,13 @@ trait Builder
|
||||
if (!is_string($condition[2])) {
|
||||
$condition[2] = $this->_hashMap($condition[2]);
|
||||
}
|
||||
$builder = Snowflake::createObject(['class' => OrCondition::class, 'value' => $condition[2], 'column' => $condition[1], 'oldParams' => $array]);
|
||||
$builder = Kiri::createObject(['class' => OrCondition::class, 'value' => $condition[2], 'column' => $condition[1], 'oldParams' => $array]);
|
||||
} else if (isset(ConditionClassMap::$conditionMap[$stroppier])) {
|
||||
$defaultConfig = ConditionClassMap::$conditionMap[$stroppier];
|
||||
$create = array_merge($defaultConfig, ['column' => $condition[1], 'value' => $condition[2]]);
|
||||
$builder = Snowflake::createObject($create);
|
||||
$builder = Kiri::createObject($create);
|
||||
} else {
|
||||
$builder = Snowflake::createObject(['class' => HashCondition::class, 'value' => $condition]);
|
||||
$builder = Kiri::createObject(['class' => HashCondition::class, 'value' => $condition]);
|
||||
}
|
||||
|
||||
$array[] = $builder->builder();
|
||||
|
||||
@@ -18,8 +18,8 @@ use Database\Query;
|
||||
use Database\SqlBuilder;
|
||||
use Exception;
|
||||
use ReflectionException;
|
||||
use Snowflake\Exception\NotFindClassException;
|
||||
use Snowflake\Snowflake;
|
||||
use Kiri\Exception\NotFindClassException;
|
||||
use Kiri\Kiri;
|
||||
|
||||
/**
|
||||
* Trait QueryTrait
|
||||
@@ -737,7 +737,7 @@ trait QueryTrait
|
||||
*/
|
||||
public function makeNewSqlGenerate(): Query
|
||||
{
|
||||
return Snowflake::createObject(['class' => Query::class]);
|
||||
return Kiri::createObject(['class' => Query::class]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user