Пример #1
0
 /**
  * Translates a database layer's field type to a mysql field type
  * @param string|zibo\library\database\definition\Field $field field can be a database layer's type or a Field object
  * @return string mysql field type
  * @throws zibo\library\database\exception\DatabaseException when no type found for the provided field or type
  */
 protected function getFieldType($field)
 {
     $fieldTypes = $this->getFieldTypes();
     if ($field instanceof Field) {
         $fieldType = $field->getType();
         if (!isset($fieldTypes[$fieldType])) {
             throw new DatabaseException('No database type found for type ' . $fieldType);
         }
         return $fieldTypes[$fieldType];
     }
     $type = array_search($field, $fieldTypes);
     if ($type === false) {
         throw new DatabaseException('No type found for database type ' . $field);
     }
     return $type;
 }