public static function SuggestionStorage::getScore in Autocomplete Search Suggestions 7
Calculate a suggestion's score.
Parameters
array $atoms: An array of strings.
Return value
int The suggestion's score.
1 call to SuggestionStorage::getScore()
- suggestion_surfer_submit in ./
suggestion.module - Custom submit function to add surfer suggestions.
File
- src/
SuggestionStorage.php, line 160 - CRUD methods for the suggestion module.
Class
- SuggestionStorage
- Database CRUD.
Code
public static function getScore(array $atoms = array()) {
$types = SuggestionHelper::types();
if (!count($types)) {
return 0;
}
$query = db_select('field_data_body', 'b');
$query
->fields('b', array(
'entity_id',
));
$query
->join('node', 'n', 'n.nid = b.entity_id');
$query
->condition('n.status', 1);
$query
->condition('n.type', $types, 'IN');
foreach ($atoms as $atom) {
$query
->condition('b.body_value', '%' . db_like($atom) . '%', 'LIKE');
}
return $query
->execute()
->rowCount();
}