/** * Search keyword/sentence string. * * @param string $keyword * @param array $matchs * @param string $table * @param array $columns * @param int $offset * @param int $limit * @return Collection */ public function search($keyword, $matchs = [], $table, $columns = ['*'], $offset = null, $limit = null) { if (empty($matchs)) { throw new Exception('Missing argument $matchs type array.'); } if (!is_null($this->limit) && is_null($limit)) { $limit = $this->limit; } try { $result = $this->sphinxQL->select($columns)->from($table)->match($matchs, $keyword); if (!is_null($offset) & !is_null($limit)) { $result = $result->limit($offset, $limit); } elseif (!is_null($offset)) { $result = $result->offset($offset); } elseif (!is_null($limit)) { $result = $result->limit($limit); } $result = $result->execute(); } catch (Exception $e) { throw $e; } return new Collection($result); }