-
- return $sql;
- }
-}
-
-class TableDef
-{
- public $name;
- public $columns;
-}
-
-class ColumnDef
-{
- public $name;
- public $type;
- public $size;
- public $nullable;
- public $key;
- public $default;
- public $extra;
-
- function __construct($name=null, $type=null, $size=null,
- $nullable=true, $key=null, $default=null,
- $extra=null) {
- $this->name = strtolower($name);
- $this->type = strtolower($type);
- $this->size = $size+0;
- $this->nullable = $nullable;
- $this->key = $key;
- $this->default = $default;
- $this->extra = $extra;
- }
-
- function equals($other)
- {
- return ($this->name == $other->name &&
- $this->_typeMatch($other) &&
- $this->_defaultMatch($other) &&
- $this->_nullMatch($other) &&
- $this->key == $other->key);
- }
-
- function _typeMatch($other)
- {
- switch ($this->type) {
- case 'integer':
- case 'int':
- return ($other->type == 'integer' ||
- $other->type == 'int');
- break;
- default:
- return ($this->type == $other->type &&
- $this->size == $other->size);