This commit is contained in:
2021-01-22 16:52:48 +08:00
parent 3d5f1e2355
commit be0161c480
2 changed files with 5 additions and 3 deletions
+3
View File
@@ -313,6 +313,9 @@ class ActiveRecord extends BaseActiveRecord
{ {
$data = $this->_attributes; $data = $this->_attributes;
foreach ($this->getAnnotation() as $key => $item) { foreach ($this->getAnnotation() as $key => $item) {
if (!isset($data[$key])) {
continue;
}
$data[$key] = call_user_func($item, $data[$key]); $data[$key] = call_user_func($item, $data[$key]);
} }
return array_merge($data, $this->runRelate()); return array_merge($data, $this->runRelate());
+2 -3
View File
@@ -11,10 +11,10 @@ namespace Database\Base;
use Annotation\Model\Get; use Annotation\Model\Get;
use ArrayAccess;
use HttpServer\Http\Context; use HttpServer\Http\Context;
use ReflectionException; use ReflectionException;
use Snowflake\Abstracts\Component; use Snowflake\Abstracts\Component;
use Snowflake\Core\Json;
use Database\ActiveQuery; use Database\ActiveQuery;
use Database\ActiveRecord; use Database\ActiveRecord;
use Database\Connection; use Database\Connection;
@@ -22,7 +22,6 @@ use Database\HasMany;
use Database\HasOne; use Database\HasOne;
use Database\Mysql\Columns; use Database\Mysql\Columns;
use Database\Relation; use Database\Relation;
use Snowflake\Error\Logger;
use Exception; use Exception;
use Snowflake\Exception\ComponentException; use Snowflake\Exception\ComponentException;
use Snowflake\Exception\NotFindClassException; use Snowflake\Exception\NotFindClassException;
@@ -39,7 +38,7 @@ use Snowflake\Snowflake;
* @method rules() * @method rules()
* @method static tableName() * @method static tableName()
*/ */
abstract class BaseActiveRecord extends Component implements IOrm, \ArrayAccess abstract class BaseActiveRecord extends Component implements IOrm, ArrayAccess
{ {
/** @var array */ /** @var array */