}
if ($i->find(true)) {
$i->encache();
- return $i;
} else {
- return NULL;
+ $i = NULL;
}
+ return $i;
}
}
return $c->get(Memcached_DataObject::cacheKey($cls, $pkeys, $pvals));
}
}
+
+ function getSearchEngine($table) {
+ require_once INSTALLDIR.'/lib/search_engines.php';
+ static $search_engine;
+ if (!isset($search_engine)) {
+ $connected = false;
+ if (common_config('sphinx', 'enabled')) {
+ $search_engine = new SphinxSearch($this, $table);
+ $connected = $search_engine->is_connected();
+ }
+
+ // unable to connect to sphinx' search daemon
+ if (!$connected) {
+ if ('mysql' === common_config('db', 'type')) {
+ $search_engine = new MySQLSearch($this, $table);
+ } else {
+ $search_engine = new PGSearch($this, $table);
+ }
+ }
+ }
+ return $search_engine;
+ }
}