9 $this->categories=array ();
12 public function add($results, $category) {
13 $count=\sizeof($this->categories);
14 if (\array_key_exists($category, $this->categories)) {
15 $this->categories[$category]->addResults($results);
17 $categoryO=
new SearchCategory(
"category" . $count, $category, $results);
18 $this->categories[$category]=$categoryO;
23 public function search($query, $field=
"title") {
25 foreach ( $this->categories as $category ) {
26 $r=$category->search($query, $field);
30 $this->categories=$result;
35 return "{\"results\":{" . \implode(
",", \array_values($this->categories)) .
"}}";
48 parent::fromDatabaseObjects($objects, $function);
52 $result=$function($object);
54 $this->categories[]=$result;
fromDatabaseObject($object, $function)
fromDatabaseObjects($objects, $function)
Loads results and categories from a collection of DB objects.
search($query, $field="title")