123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- <?php
- if (!defined('STATUSNET')) {
- exit(1);
- }
- class ColumnDef
- {
-
- public $name;
-
- public $type;
-
- public $size;
-
- public $nullable;
-
- public $key;
-
- public $default;
-
- public $extra;
-
- public $auto_increment;
-
- function __construct($name=null, $type=null, $size=null,
- $nullable=true, $key=null, $default=null,
- $extra=null, $auto_increment=false)
- {
- $this->name = strtolower($name);
- $this->type = strtolower($type);
- $this->size = $size+0;
- $this->nullable = $nullable;
- $this->key = $key;
- $this->default = $default;
- $this->extra = $extra;
- $this->auto_increment = $auto_increment;
- }
-
- function equals($other)
- {
- return ($this->name == $other->name &&
- $this->_typeMatch($other) &&
- $this->_defaultMatch($other) &&
- $this->_nullMatch($other) &&
- $this->key == $other->key &&
- $this->auto_increment == $other->auto_increment);
- }
-
- private 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);
- }
- }
-
- private function _defaultMatch($other)
- {
- return ((is_null($this->default) && is_null($other->default)) ||
- ($this->default == $other->default));
- }
-
- private function _nullMatch($other)
- {
- return ((!is_null($this->default) && !is_null($other->default) &&
- $this->default == $other->default) ||
- ($this->nullable == $other->nullable));
- }
- }
|