summaryrefslogtreecommitdiff
path: root/lib/schema.php
diff options
context:
space:
mode:
authorBrion Vibber <brion@pobox.com>2009-11-24 09:38:16 -0800
committerBrion Vibber <brion@pobox.com>2009-11-24 09:38:16 -0800
commit2da531d7d65044f3093eafd72b73a08e1cf67fd5 (patch)
tree3f6c77dc807728e1ec852ee2f2209623233d9617 /lib/schema.php
parent84ed094f40d4087704fc3354ea4c3743b1447331 (diff)
Break TableDef, ColumnDef classes to separate files so autoloader can find them.
With $config['db']['schemacheck'] set to 'script' in live deployment, Schema class wasn't being preloaded for us; the uses of TableDef by plugins for DataObject configuration would then fail because the class wasn't loaded. Broken to separate files, the autoloader can find all classes in either case. PHP Fatal error: Class 'TableDef' not found in /var/www/statusnet/plugins/OpenID/User_openid.php on line 43, referer: http://identi.ca/brionv/all
Diffstat (limited to 'lib/schema.php')
-rw-r--r--lib/schema.php168
1 files changed, 0 insertions, 168 deletions
diff --git a/lib/schema.php b/lib/schema.php
index 560884d9f..11e2b6f60 100644
--- a/lib/schema.php
+++ b/lib/schema.php
@@ -547,171 +547,3 @@ class Schema
return $sql;
}
}
-
-/**
- * A class encapsulating the structure of a table.
- *
- * @category Database
- * @package StatusNet
- * @author Evan Prodromou <evan@status.net>
- * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
- * @link http://status.net/
- */
-
-class TableDef
-{
- /** name of the table */
- public $name;
- /** array of ColumnDef objects for the columns. */
- public $columns;
-
- /**
- * Constructor.
- *
- * @param string $name name of the table
- * @param array $columns columns in the table
- */
-
- function __construct($name=null,$columns=null)
- {
- $this->name = $name;
- $this->columns = $columns;
- }
-}
-
-/**
- * A class encapsulating the structure of a column in a table.
- *
- * @category Database
- * @package StatusNet
- * @author Evan Prodromou <evan@status.net>
- * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
- * @link http://status.net/
- */
-
-class ColumnDef
-{
- /** name of the column. */
- public $name;
- /** type of column, e.g. 'int', 'varchar' */
- public $type;
- /** size of the column. */
- public $size;
- /** boolean flag; can it be null? */
- public $nullable;
- /**
- * type of key: null = no key; 'PRI' => primary;
- * 'UNI' => unique key; 'MUL' => multiple values.
- */
- public $key;
- /** default value if any. */
- public $default;
- /** 'extra' stuff. Returned by MySQL, largely
- * unused. */
- public $extra;
- /** auto increment this field if no value is specific for it during an insert **/
- public $auto_increment;
-
- /**
- * Constructor.
- *
- * @param string $name name of the column
- * @param string $type type of the column
- * @param int $size size of the column
- * @param boolean $nullable can this be null?
- * @param string $key type of key
- * @param value $default default value
- * @param value $extra unused
- */
-
- 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;
- }
-
- /**
- * Compares this columndef with another to see
- * if they're functionally equivalent.
- *
- * @param ColumnDef $other column to compare
- *
- * @return boolean true if equivalent, otherwise false.
- */
-
- 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);
- }
-
- /**
- * Does the type of this column match the
- * type of the other column?
- *
- * Checks the type and size of a column. Tries
- * to ignore differences between synonymous
- * data types, like 'integer' and 'int'.
- *
- * @param ColumnDef $other other column to check
- *
- * @return boolean true if they're about equivalent
- */
-
- 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);
- }
- }
-
- /**
- * Does the default behaviour of this column match
- * the other?
- *
- * @param ColumnDef $other other column to check
- *
- * @return boolean true if defaults are effectively the same.
- */
-
- private function _defaultMatch($other)
- {
- return ((is_null($this->default) && is_null($other->default)) ||
- ($this->default == $other->default));
- }
-
- /**
- * Does the null behaviour of this column match
- * the other?
- *
- * @param ColumnDef $other other column to check
- *
- * @return boolean true if these columns 'null' the same.
- */
-
- private function _nullMatch($other)
- {
- return ((!is_null($this->default) && !is_null($other->default) &&
- $this->default == $other->default) ||
- ($this->nullable == $other->nullable));
- }
-}