public function loadColumns() { $sql = 'SHOW COLUMNS FROM `' . $this->getTableName() . '`'; $result = $this->query($sql); while ($row = mysql_fetch_assoc($result)) { $column = new SchemaColumn(); $column->setTable($this); $column->setColumnName($row['Field']); $column->setIsNullAllowed(strtolower($row['Null']) == 'yes'); $column->setDefaultValue($row['Default']); // value from MySQL will be PHP null, false, true, or a string $column->setIsPrimaryKey($row['Key'] == 'PRI'); // Set type and size of column $typePieces = preg_split('/[\\(\\)]/', $row['Type']); $column->setType($typePieces[0]); if (count($typePieces) > 1) { $column->setSize($typePieces[1]); } $this->addColumn($column); } $sql = 'SHOW CREATE TABLE `' . $this->getTableName() . '`'; $result = $this->query($sql); while ($row = mysql_fetch_assoc($result)) { if (isset($row['Create Table'])) { $this->parseCreateStatement($row['Create Table']); } } }