public function fromTable(string
$table) { $this->prefixedTableName =
$table;
$prefix =
$this->db->DBPrefix;
if (!
empty($prefix) &&
strpos($table,
$prefix) === 0
) { $table =
substr($table,
strlen($prefix));
} if (!
$this->db->
tableExists($this->prefixedTableName
)) { throw DataException::
forTableNotFound($this->prefixedTableName
);
} $this->tableName =
$table;
$this->fields =
$this->
formatFields($this->db->
getFieldData($table));
$this->keys =
array_merge($this->keys,
$this->
formatKeys($this->db->
getIndexData($table)));
// if primary key index exists twice then remove psuedo index name 'primary'.
$primaryIndexes =
array_filter($this->keys,
static fn ($index) =>
$index['type'
] === 'primary'
);