summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/SemanticMediaWiki/src/SQLStore/TableBuilder/FieldType.php
diff options
context:
space:
mode:
Diffstat (limited to 'www/wiki/extensions/SemanticMediaWiki/src/SQLStore/TableBuilder/FieldType.php')
-rw-r--r--www/wiki/extensions/SemanticMediaWiki/src/SQLStore/TableBuilder/FieldType.php131
1 files changed, 131 insertions, 0 deletions
diff --git a/www/wiki/extensions/SemanticMediaWiki/src/SQLStore/TableBuilder/FieldType.php b/www/wiki/extensions/SemanticMediaWiki/src/SQLStore/TableBuilder/FieldType.php
new file mode 100644
index 00000000..8b5ba88f
--- /dev/null
+++ b/www/wiki/extensions/SemanticMediaWiki/src/SQLStore/TableBuilder/FieldType.php
@@ -0,0 +1,131 @@
+<?php
+
+namespace SMW\SQLStore\TableBuilder;
+
+/**
+ * @private
+ *
+ * @license GNU GPL v2+
+ * @since 2.5
+ *
+ * @author mwjames
+ */
+class FieldType {
+
+ /**
+ * @var string
+ */
+ const FIELD_ID = 'id';
+
+ /**
+ * @var string
+ */
+ const FIELD_ID_PRIMARY = 'id_primary';
+
+ /**
+ * @var string
+ */
+ const FIELD_ID_UNSIGNED = 'id_unsigned';
+
+ /**
+ * @var string
+ */
+ const FIELD_TITLE = 'title';
+
+ /**
+ * @var string
+ */
+ const FIELD_HASH = 'hash';
+
+ /**
+ * @var string
+ */
+ const FIELD_NAMESPACE = 'namespace';
+
+ /**
+ * @var string
+ */
+ const FIELD_INTERWIKI = 'interwiki';
+
+ /**
+ * @var string
+ */
+ const FIELD_USAGE_COUNT = 'usage_count';
+
+ /**
+ * @var string
+ */
+ const TYPE_CHAR_NOCASE = 'char_nocase';
+
+ /**
+ * @var string
+ */
+ const TYPE_CHAR_LONG = 'char_long';
+
+ /**
+ * @var string
+ */
+ const TYPE_CHAR_LONG_NOCASE = 'char_long_nocase';
+
+ /**
+ * @var integer
+ */
+ const CHAR_LONG_LENGTH = 300;
+
+ /**
+ * @var string
+ */
+ const TYPE_BOOL = 'boolean';
+
+ /**
+ * @var string
+ */
+ const TYPE_INT = 'integer';
+
+ /**
+ * @var string
+ */
+ const TYPE_INT_UNSIGNED = 'integer_unsigned';
+
+ /**
+ * @var string
+ */
+ const TYPE_TEXT = 'text';
+
+ /**
+ * @var string
+ */
+ const TYPE_BLOB = 'blob';
+
+ /**
+ * @var string
+ */
+ const TYPE_DOUBLE = 'double';
+
+ /**
+ * @since 2.5
+ *
+ * @param string|array $type
+ * @param array $fieldTypes
+ */
+ public static function mapType( $type, $fieldTypes = [] ) {
+
+ $fieldType = $type;
+ $auxilary = '';
+
+ // [ FieldType::FIELD_ID, 'NOT NULL' ]
+ if ( is_array( $type ) && count( $type ) > 1 ) {
+ $fieldType = $type[0];
+ $auxilary = ' ' . $type[1];
+ } elseif ( is_array( $type ) ) {
+ $fieldType = $type[0];
+ }
+
+ if ( isset( $fieldTypes[$fieldType] ) ) {
+ $fieldType = $fieldTypes[$fieldType];
+ }
+
+ return $fieldType . $auxilary;
+ }
+
+}