Commit eadc0cb5 authored by Geoff Cant's avatar Geoff Cant Committed by Geoff Cant
Browse files

Adds mysql support for search_group in the search plugin.

parent 5329c1e0
......@@ -259,6 +259,8 @@ class PluginSearchInternal extends PluginSearch {
public static function search_group($query_string, $limit, $offset = 0) {
if ( is_postgres() ) {
return search_group_pg($query_string, $limit, $offset);
} else if ( is_mysql() ) {
return search_group_my($query_string, $limit, $offset);
} else {
throw new SQLException('search_group() is not implemented for your database engine (' . get_config('dbtype') . ')');
}
......@@ -305,6 +307,48 @@ class PluginSearchInternal extends PluginSearch {
'data' => $data,
);
}
public static function search_group_my($query_string, $limit, $offset) {
global $USER;
$data = get_records_sql_array("
SELECT
id, name, owner, description, ctime, mtime
FROM
" . get_config('dbprefix') . "usr_group u
WHERE
owner = ?
AND (
name LIKE '%' || ? || '%'
OR description LIKE '%' || ? || '%'
)
",
array($USER->get('id'), $query_string, $query_string),
$offset,
$limit
);
$count = get_field_sql("
SELECT
COUNT(*)
FROM
" . get_config('dbprefix') . "usr_group u
WHERE
owner = ?
AND (
name LIKE '%' || ? || '%'
OR description LIKE '%' || ? || '%'
)
",
array($USER->get('id'), $query_string, $query_string)
);
return array(
'count' => $count,
'limit' => $limit,
'offset' => $offset,
'data' => $data,
);
}
/**
* Implement community searching with SQL
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment