summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorEvan Prodromou <evan@controlyourself.ca>2009-06-21 21:50:35 -0700
committerEvan Prodromou <evan@controlyourself.ca>2009-06-21 21:50:35 -0700
commit876ab059273a5f223170d6b2c0b9b4342b06c50f (patch)
tree5a3f32ead088c405bf24ddff361ed5cbed47db8c /lib
parent02a4ca9e2ea46cb82829dc65e76efc36b0ec470b (diff)
Add like for search
Diffstat (limited to 'lib')
-rw-r--r--lib/common.php4
-rw-r--r--lib/search_engines.php22
2 files changed, 25 insertions, 1 deletions
diff --git a/lib/common.php b/lib/common.php
index 361759d0a..14f5c7a7f 100644
--- a/lib/common.php
+++ b/lib/common.php
@@ -228,7 +228,9 @@ $config =
),
'group' =>
array('maxaliases' => 3),
- 'oohembed' => array('endpoint' => 'http://oohembed.com/oohembed/')
+ 'oohembed' => array('endpoint' => 'http://oohembed.com/oohembed/'),
+ 'search' =>
+ array('type' => 'fulltext'),
);
$config['db'] = &PEAR::getStaticProperty('DB_DataObject','options');
diff --git a/lib/search_engines.php b/lib/search_engines.php
index c98e8ed87..5c84d7c6b 100644
--- a/lib/search_engines.php
+++ b/lib/search_engines.php
@@ -131,6 +131,28 @@ class MySQLSearch extends SearchEngine
}
}
+class MySQLLikeSearch extends SearchEngine
+{
+ function query($q)
+ {
+ if ('identica_people' === $this->table) {
+ $qry = sprintf('(nickname LIKE "%%%1$s%%" OR '.
+ ' fullname LIKE "%%%1$s%%" OR '.
+ ' location LIKE "%%%1$s%%" OR '.
+ ' bio LIKE "%%%1$s%%" OR '.
+ ' homepage LIKE "%%%1$s%%")', addslashes($q));
+ } else if ('identica_notices' === $this->table) {
+ $qry = sprintf('content LIKE "%%%1$s%%"', addslashes($q));
+ } else {
+ throw new ServerException('Unknown table: ' . $this->table);
+ }
+
+ $this->target->whereAdd($qry);
+
+ return true;
+ }
+}
+
class PGSearch extends SearchEngine
{
function query($q)