protected function SearchApiDbService::sqlType in Search API Database Search 7
Returns the schema definition for a database column for a search data type.
Parameters
string $type: An indexed field's search type. One of the keys from search_api_default_field_types().
Return value
array Column configurations to use for the field's database column.
Throws
SearchApiException If $type is unknown.
2 calls to SearchApiDbService::sqlType()
- SearchApiDbService::createFieldTable in ./
service.inc - Creates or modifies a table to add an indexed field.
- SearchApiDbService::fieldsUpdated in ./
service.inc - Overrides SearchApiAbstractService::fieldsUpdated().
File
- ./
service.inc, line 480 - Contains SearchApiDbService.
Class
- SearchApiDbService
- Indexes and searches items using the database.
Code
protected function sqlType($type) {
$type = search_api_extract_inner_type($type);
switch ($type) {
case 'string':
case 'uri':
return array(
'type' => 'varchar',
'length' => 255,
);
case 'integer':
case 'duration':
case 'date':
// 'datetime' sucks. Therefore, we just store the timestamp.
return array(
'type' => 'int',
'size' => 'big',
);
case 'decimal':
return array(
'type' => 'float',
);
case 'boolean':
return array(
'type' => 'int',
'size' => 'tiny',
);
default:
throw new SearchApiException(t('Unknown field type @type. Database search module might be out of sync with Search API.', array(
'@type' => $type,
)));
}
}