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 getTableReference() { return TableReference::getByTableName($this->table); }