94 lines
3.1 KiB
PHP

<?php
namespace Ulmus\Entity\InformationSchema;
use Ulmus\EntityCollection,
Ulmus\Entity\Field\Datetime;
use Ulmus\{Attribute\Obj\Table as TableObj, Entity\EntityInterface};
use Ulmus\Attribute\Property\{Field, Filter, FilterJoin, Relation, Join, Virtual, Where};
#[TableObj(name: "tables", database: "information_schema")]
class Table implements EntityInterface
{
use \Ulmus\EntityTrait;
#[Field(name: "TABLE_CATALOG", length: 512)]
public string $catalog;
#[Field(name: "TABLE_SCHEMA", length: 64)]
public string $schema;
#[Field(name: "TABLE_NAME", length: 64, attributes: [ 'primary_key' => true, ])]
public string $name;
#[Field(name: "TABLE_TYPE", length: 64)]
public string $type;
#[Field(name: "ENGINE", length: 64)]
public ? string $engine ;
#[Field(name: "VERSION", type: "bigint", length: 21, attributes: [ 'unsigned' => true, ])]
public ? string $version;
#[Field(name: "ROW_FORMAT", length: 10)]
public ? string $rowFormat;
#[Field(name: "TABLE_ROWS", type: "bigint", length: 21, attributes: [ 'unsigned' => true, ])]
public ? string $rows;
#[Field(name: "AVG_ROW_LENGTH", type: "bigint", length: 21, attributes: [ 'unsigned' => true, ])]
public ? string $averageRowLength;
#[Field(name: "DATA_LENGTH", type: "bigint", length: 21, attributes: [ 'unsigned' => true, ])]
public ? string $dataLength;
#[Field(name: "MAX_DATA_LENGTH", type: "bigint", length: 21, attributes: [ 'unsigned' => true, ])]
public ? string $maxDataLength;
#[Field(name: "INDEX_LENGTH", type: "bigint", length: 21, attributes: [ 'unsigned' => true, ])]
public ? string $indexLength;
#[Field(name: "DATA_FREE", type: "bigint", length: 21, attributes: [ 'unsigned' => true, ])]
public ? string $dataFree;
#[Field(name: "AUTO_INCREMENT", type: "bigint", length: 21, attributes: [ 'unsigned' => true, ])]
public ? string $autoIncrement;
#[Field(name: "CREATE_TIME")]
public ? Datetime $createTime;
#[Field(name: "UPDATE_TIME")]
public ? Datetime $updateTime;
#[Field(name: "CHECK_TIME")]
public ? Datetime $checkTime;
#[Field(name: "TABLE_COLLATION", length: 32)]
public ? string $tableCollation;
#[Field(name: "CHECKSUM", type: "bigint", length: 21, attributes: [ 'unsigned' => true, ])]
public ? string $checksum;
#[Field(name: "CREATE_OPTIONS", length: 2048)]
public ? string $createOptions;
#[Field(name: "TABLE_COMMENT", length: 2048)]
public string $tableComment;
#[Field(name: "MAX_INDEX_LENGTH", type: "bigint", length: 21, attributes: [ 'unsigned' => true, ])]
public ? int $maxIndexLength;
#[Field(name: "TEMPORARY", length: 1)]
public ? string $temporary;
#[Relation(type: "oneToMany", key: "name", foreignKey: [ Column::class, 'tableName' ], entity: Column::class)]
#[Where(field: 'TABLE_SCHEMA', generateValue: [ Table::class, 'getSchema' ])]
public EntityCollection $columns;
# Awaiting PHP 8.5 https://wiki.php.net/rfc/closures_in_const_expr
public static function getSchema(Table $entity) : string
{
return $entity->schema;
}
}