This commit is contained in:
2020-11-05 19:02:24 +08:00
parent 66ead1e77f
commit f4487f5ca3
+5 -5
View File
@@ -60,7 +60,8 @@ class Columns extends Component
*/
public function table(string $table)
{
return $this->structure($this->table = $table);
$this->structure($this->table = $table);
return $this;
}
/**
@@ -263,7 +264,7 @@ class Columns extends Component
*/
private function getColumns()
{
return $this->structure($this->getTable())->columns[$this->getTable()];
return $this->structure($this->getTable());
}
@@ -275,15 +276,14 @@ class Columns extends Component
private function structure($table)
{
if (isset($this->columns[$table])) {
return $this;
return $this->columns[$table];
}
$sql = $this->db->getBuild()->getColumn($table);
$column = $this->db->createCommand($sql)->all();
if (empty($column)) {
throw new Exception("The table " . $table . " not exists.");
}
$this->columns[$table] = $this->resolve($column, $table);
return $this;
return $this->columns[$table] = $this->resolve($column, $table);
}