public function __construct(Database $database, Table $table, $info) { // Table $this->table = $table; // Name $this->name = $info->Field; // Type $this->parse_type($info->Type); // Default $this->default_value = $info->Default; // Primary key if (strtoupper($info->Key) == 'PRI') { $this->is_primary_key = true; if ($info->Extra == 'auto_increment') { $this->is_auto_increment = true; } } // Unique key if (strtoupper($info->Key) == 'UNI') { $this->is_unique = true; } // Comment $this->comment = $info->Comment; // Collation $this->collation = $info->Collation; // NULL? $this->nullable = $info->Null == 'YES'; // Is this a foreign key? if (in_array($this->name, $table->get_foreign_key_names())) { $referencedTables = $table->getReferencedTables(false); $this->references = $referencedTables[$this->name]; } }