modify plugin name
This commit is contained in:
+1
-1
@@ -13,7 +13,7 @@ use Exception;
|
|||||||
* Class Get
|
* Class Get
|
||||||
* @package Annotation\Model
|
* @package Annotation\Model
|
||||||
*/
|
*/
|
||||||
#[Attribute(Attribute::TARGET_METHOD)] class Get extends \Kiri\Annotation\Attribute
|
#[Attribute(Attribute::TARGET_METHOD)] class Get extends \Kiri\Annotation\AbstractAttribute
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
namespace Database\Annotation;
|
namespace Database\Annotation;
|
||||||
|
|
||||||
|
|
||||||
use Kiri\Annotation\Attribute;
|
use Kiri\Annotation\AbstractAttribute;
|
||||||
use Database\Base\Relate;
|
use Database\Base\Relate;
|
||||||
use Exception;
|
use Exception;
|
||||||
|
|
||||||
@@ -13,7 +13,7 @@ use Exception;
|
|||||||
* Class Relation
|
* Class Relation
|
||||||
* @package Annotation\Model
|
* @package Annotation\Model
|
||||||
*/
|
*/
|
||||||
#[\Attribute(\Attribute::TARGET_METHOD)] class Relation extends Attribute
|
#[\Attribute(\Attribute::TARGET_METHOD)] class Relation extends AbstractAttribute
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -4,11 +4,11 @@
|
|||||||
namespace Database\Annotation;
|
namespace Database\Annotation;
|
||||||
|
|
||||||
|
|
||||||
use Kiri\Annotation\Attribute;
|
use Kiri\Annotation\AbstractAttribute;
|
||||||
use Database\Base\Setter;
|
use Database\Base\Setter;
|
||||||
use Exception;
|
use Exception;
|
||||||
|
|
||||||
#[\Attribute(\Attribute::TARGET_METHOD)] class Set extends Attribute
|
#[\Attribute(\Attribute::TARGET_METHOD)] class Set extends AbstractAttribute
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+8
-5
@@ -25,9 +25,11 @@ use Database\Relation;
|
|||||||
use Database\SqlBuilder;
|
use Database\SqlBuilder;
|
||||||
use Database\Traits\HasBase;
|
use Database\Traits\HasBase;
|
||||||
use Exception;
|
use Exception;
|
||||||
use Kiri\Abstracts\Component;
|
|
||||||
use Kiri\Exception\NotFindClassException;
|
|
||||||
use Kiri;
|
use Kiri;
|
||||||
|
use Kiri\Abstracts\Component;
|
||||||
|
use Kiri\Annotation\Annotation;
|
||||||
|
use Kiri\Error\StdoutLogger;
|
||||||
|
use Kiri\Exception\NotFindClassException;
|
||||||
use Kiri\ToArray;
|
use Kiri\ToArray;
|
||||||
use ReflectionException;
|
use ReflectionException;
|
||||||
use ReturnTypeWillChange;
|
use ReturnTypeWillChange;
|
||||||
@@ -198,7 +200,7 @@ abstract class Model extends Component implements ModelInterface, ArrayAccess, T
|
|||||||
*/
|
*/
|
||||||
public function init()
|
public function init()
|
||||||
{
|
{
|
||||||
$an = Kiri::app()->getAnnotation();
|
$an = Kiri::getDi()->get(Annotation::class);
|
||||||
$an->injectProperty($this);
|
$an->injectProperty($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -238,7 +240,8 @@ abstract class Model extends Component implements ModelInterface, ArrayAccess, T
|
|||||||
*/
|
*/
|
||||||
public function getLastError(): string
|
public function getLastError(): string
|
||||||
{
|
{
|
||||||
return Kiri::app()->getLogger()->getLastError('mysql');
|
$logger = Kiri::getDi()->get(StdoutLogger::class);
|
||||||
|
return $logger->getLastError('mysql');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -646,7 +649,7 @@ abstract class Model extends Component implements ModelInterface, ArrayAccess, T
|
|||||||
if (empty($rule)) return TRUE;
|
if (empty($rule)) return TRUE;
|
||||||
$validate = $this->resolve($rule);
|
$validate = $this->resolve($rule);
|
||||||
if (!$validate->validation()) {
|
if (!$validate->validation()) {
|
||||||
return $this->addError($validate->getError(), 'mysql');
|
return $this->logger->addError($validate->getError(), 'mysql');
|
||||||
} else {
|
} else {
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -133,7 +133,7 @@ class Command extends Component
|
|||||||
private function _timeout_log(float $time, mixed $result): mixed
|
private function _timeout_log(float $time, mixed $result): mixed
|
||||||
{
|
{
|
||||||
if (microtime(true) - $time >= 0.02) {
|
if (microtime(true) - $time >= 0.02) {
|
||||||
$this->warning('Mysql:' . Json::encode([$this->sql, $this->params]) . (microtime(true) - $time));
|
$this->logger->warning('Mysql:' . Json::encode([$this->sql, $this->params]) . (microtime(true) - $time));
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
@@ -149,7 +149,7 @@ class Command extends Component
|
|||||||
try {
|
try {
|
||||||
$result = $pdo->execute($this->sql, $this->params);
|
$result = $pdo->execute($this->sql, $this->params);
|
||||||
} catch (\Throwable $exception) {
|
} catch (\Throwable $exception) {
|
||||||
$result = $this->addError($this->sql . '. error: ' . $exception->getMessage(), 'mysql');
|
$result = $this->logger->addError($this->sql . '. error: ' . $exception->getMessage(), 'mysql');
|
||||||
} finally {
|
} finally {
|
||||||
$this->db->release();
|
$this->db->release();
|
||||||
return $result;
|
return $result;
|
||||||
@@ -168,7 +168,7 @@ class Command extends Component
|
|||||||
try {
|
try {
|
||||||
$data = $pdo->{$type}($this->sql, $this->params);
|
$data = $pdo->{$type}($this->sql, $this->params);
|
||||||
} catch (\Throwable $throwable) {
|
} catch (\Throwable $throwable) {
|
||||||
$data = $this->addError($this->sql . '. error: ' . $throwable->getMessage(), 'mysql');
|
$data = $this->logger->addError($this->sql . '. error: ' . $throwable->getMessage(), 'mysql');
|
||||||
} finally {
|
} finally {
|
||||||
$this->db->releaseSlaveConnect($pdo);
|
$this->db->releaseSlaveConnect($pdo);
|
||||||
return $data;
|
return $data;
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ use Exception;
|
|||||||
use Kiri;
|
use Kiri;
|
||||||
use Kiri\Exception\NotFindClassException;
|
use Kiri\Exception\NotFindClassException;
|
||||||
use Kiri\ToArray;
|
use Kiri\ToArray;
|
||||||
|
use Kiri\Error\StdoutLogger;
|
||||||
use ReflectionException;
|
use ReflectionException;
|
||||||
use Swoole\Coroutine;
|
use Swoole\Coroutine;
|
||||||
|
|
||||||
@@ -108,7 +109,7 @@ class Model extends Base\Model
|
|||||||
*/
|
*/
|
||||||
public static function findOrCreate(array $condition, array $attributes): bool|static
|
public static function findOrCreate(array $condition, array $attributes): bool|static
|
||||||
{
|
{
|
||||||
$logger = Kiri::app()->getLogger();
|
$logger = Kiri::getDi()->get(StdoutLogger::class);
|
||||||
if (empty($attributes)) {
|
if (empty($attributes)) {
|
||||||
return $logger->addError(FIND_OR_CREATE_MESSAGE, 'mysql');
|
return $logger->addError(FIND_OR_CREATE_MESSAGE, 'mysql');
|
||||||
}
|
}
|
||||||
@@ -133,7 +134,7 @@ class Model extends Base\Model
|
|||||||
*/
|
*/
|
||||||
public static function createOrUpdate(array $condition, array $attributes = []): bool|static
|
public static function createOrUpdate(array $condition, array $attributes = []): bool|static
|
||||||
{
|
{
|
||||||
$logger = Kiri::app()->getLogger();
|
$logger = Kiri::getDi()->get(StdoutLogger::class);
|
||||||
if (empty($attributes)) {
|
if (empty($attributes)) {
|
||||||
return $logger->addError(FIND_OR_CREATE_MESSAGE, 'mysql');
|
return $logger->addError(FIND_OR_CREATE_MESSAGE, 'mysql');
|
||||||
}
|
}
|
||||||
@@ -207,7 +208,7 @@ class Model extends Base\Model
|
|||||||
{
|
{
|
||||||
$primary = $this->getPrimary();
|
$primary = $this->getPrimary();
|
||||||
if (empty($primary) || !$this->hasPrimaryValue()) {
|
if (empty($primary) || !$this->hasPrimaryValue()) {
|
||||||
return $this->addError("Only primary key operations are supported.", 'mysql');
|
return $this->logger->addError("Only primary key operations are supported.", 'mysql');
|
||||||
}
|
}
|
||||||
if ($this->beforeDelete()) {
|
if ($this->beforeDelete()) {
|
||||||
$result = static::deleteByCondition([$primary => $this->getPrimaryValue()]);
|
$result = static::deleteByCondition([$primary => $this->getPrimaryValue()]);
|
||||||
|
|||||||
+2
-2
@@ -149,7 +149,7 @@ class Pagination extends Component
|
|||||||
try {
|
try {
|
||||||
call_user_func($this->_callback, $data, $param);
|
call_user_func($this->_callback, $data, $param);
|
||||||
} catch (\Throwable $exception) {
|
} catch (\Throwable $exception) {
|
||||||
$this->addError($exception, 'throwable');
|
$this->logger->addError($exception, 'throwable');
|
||||||
} finally {
|
} finally {
|
||||||
$data = null;
|
$data = null;
|
||||||
}
|
}
|
||||||
@@ -179,7 +179,7 @@ class Pagination extends Component
|
|||||||
try {
|
try {
|
||||||
call_user_func($this->_callback, $data, $param);
|
call_user_func($this->_callback, $data, $param);
|
||||||
} catch (\Throwable $exception) {
|
} catch (\Throwable $exception) {
|
||||||
$this->addError($exception, 'throwable');
|
$this->logger->addError($exception, 'throwable');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -93,7 +93,7 @@ class SqlBuilder extends Component
|
|||||||
private function __updateBuilder(array $string, array $params): array|bool
|
private function __updateBuilder(array $string, array $params): array|bool
|
||||||
{
|
{
|
||||||
if (empty($string)) {
|
if (empty($string)) {
|
||||||
return $this->addError('None data update.');
|
return $this->logger->addError('None data update.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$condition = $this->conditionToString();
|
$condition = $this->conditionToString();
|
||||||
|
|||||||
Reference in New Issue
Block a user