function filter($text, SelectStatement $sql, $table) { $table = TableReference::getByTableName($table); if ($table === null) { throw new \Exception('Couldnt find table model "' . $table . '" to search'); } $where = new WhereOR(); $useWhere = false; $k = null; $i = array(); $rows = $this->Search($text, $table); foreach ($rows as $row) { if (count($row) == 1) { $a = array_keys($row->toArray()); $b = array_values($row->toArray()); $k = $a[0]; $i[] = $b[0]; } else { $where->Add(new Where($row)); $useWhere = true; } } if ($useWhere) { $sql->where_and($where); } else { $in = new In($i); $in = new Comparison($k, $in, ''); $sql->where_and($in); } }
function getCount() { if ($this->count !== null) { if ($this->count instanceof SelectStatement) { $this->count = $this->count->query()->fetch(Fetch::FIRST); } return $this->count; } if ($this->data) { return $this->count = count($this->data); } $this->count = $this->sql->getCount(); return $this->count; }
protected function _Filter($text, SelectStatement $sql) { $ft = new Fulltext($text, $this->fields, $this->isBoolean()); $sql->where_and($ft); }