改名
This commit is contained in:
@@ -12,8 +12,6 @@ namespace Database\Base;
|
||||
|
||||
use Annotation\Event;
|
||||
use Annotation\Inject;
|
||||
use Annotation\Model\Get;
|
||||
use Annotation\Model\Set;
|
||||
use ArrayAccess;
|
||||
use Database\SqlBuilder;
|
||||
use Database\Traits\HasBase;
|
||||
@@ -75,8 +73,6 @@ abstract class BaseActiveRecord extends Component implements IOrm, ArrayAccess
|
||||
private array $_annotations = [];
|
||||
|
||||
|
||||
private array $_fields = [];
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
@@ -756,10 +752,7 @@ abstract class BaseActiveRecord extends Component implements IOrm, ArrayAccess
|
||||
*/
|
||||
public function has($attribute): bool
|
||||
{
|
||||
if (empty($this->_fields)) {
|
||||
$this->_fields = static::getColumns()->format();
|
||||
}
|
||||
return isset($this->_fields[$attribute]);
|
||||
return static::getColumns()->hasField($attribute);
|
||||
}
|
||||
|
||||
/**ƒ
|
||||
|
||||
@@ -55,6 +55,9 @@ class Columns extends Component
|
||||
*/
|
||||
private array $_auto_increment = [];
|
||||
|
||||
|
||||
private array $_fields = [];
|
||||
|
||||
/**
|
||||
* @param string $table
|
||||
* @return $this
|
||||
@@ -206,6 +209,31 @@ class Columns extends Component
|
||||
return $this->columns('Default', 'Field');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getFields(): array
|
||||
{
|
||||
if (empty($this->_fields)) {
|
||||
$this->structure($this->table);
|
||||
}
|
||||
return $this->_fields[$this->table];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @return bool
|
||||
* @throws Exception
|
||||
*/
|
||||
public function hasField(string $name): bool
|
||||
{
|
||||
return isset($this->getFields()[$name]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return int|string|null
|
||||
* @throws Exception
|
||||
@@ -282,7 +310,6 @@ class Columns extends Component
|
||||
throw new Exception("The table " . $table . " not exists.");
|
||||
}
|
||||
return $this->columns[$table] = $this->resolve($column, $table);
|
||||
|
||||
}
|
||||
return $this->columns[$table];
|
||||
}
|
||||
@@ -299,6 +326,9 @@ class Columns extends Component
|
||||
$this->addPrimary($item, $table);
|
||||
$column[$key]['Type'] = $this->clean($item['Type']);
|
||||
}
|
||||
|
||||
$this->_fields[$table] = array_column($column, 'Default', 'Field');
|
||||
|
||||
return $column;
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ class OnReceive extends Callback
|
||||
* @return mixed
|
||||
* @throws Exception
|
||||
*/
|
||||
public function onHandler(\Swoole\Server $server, int $fd, int $reID, string $data): mixed
|
||||
public function onHandler(Server $server, int $fd, int $reID, string $data): mixed
|
||||
{
|
||||
try {
|
||||
$client = $server->getClientInfo($fd, $reID);
|
||||
|
||||
Reference in New Issue
Block a user