public function search($val, $exact = false) { $dbIndices = new self('indices', $this->table); $rows = $dbIndices->cursor(); $ids = []; foreach ($rows as $row) { foreach ($row as $k => $v) { if (!$exact) { if (fnmatch("*{$val}*", $v)) { $ids[] = $row['object_id']; break; } } else { if ($val == $v) { $ids[] = $row['object_id']; break; } } } } return !empty($ids) ? $this->where(['id', 'IN', implode(',', $ids)]) : $this; }