Can search for users and groups from the API

This commit is contained in:
Pierre HUBERT
2018-07-28 17:15:50 +02:00
parent eea4378a9c
commit 53b72bd767
4 changed files with 148 additions and 43 deletions

View File

@ -37,6 +37,34 @@ class search {
//Return result
return $return;
}
/**
* Search for groups in the database
*
* @param string $query
* @param int $limit (default = 10)
* @return array List of results
*/
public function search_group(string $query, int $limit = 10){
//Query string
$query = "%".$query."%";
//Request
$results = db()->select(
GroupsComponent::GROUPS_LIST_TABLE,
"WHERE name LIKE ?",
array($query),
array("id")
);
//Parse and return results
$list = array();
foreach($results as $el)
$list[] = $el["id"];
return $list;
}
}
//Register class