V
V
v3shin2016-12-20 14:58:32
Sphinx
v3shin, 2016-12-20 14:58:32

How to search in sphinx using and and or?

Good day.
There is a code with something like this logic:

$condition = '';
$order = 'id desc';
$limit = '0,30';

if($params['id'] == 0){
  $condition = '
    (user_id = :user_id and !user_deleted)
    or (from_id = :user_id and !from_deleted)
  ';
} else {
  $condition = '
    (user_id = :user_id and from_id = :from_id and !user_deleted)
    or (user_id = :from_id and from_id = :user_id and !from_deleted)
  ';
}

if(isset($params['lastId']) && $params['lastId']){
  $condition = '('.$condition.') and id > :lastId';
  if(!isset($params['firstId']) || !$params['firstId']){
    $order = 'id asc';
  }
}
if(isset($params['firstId']) && $params['firstId']){
  $condition = '('.$condition.') and id < :firstId';
}
if(isset($params['text']) && $params['text']){
  $condition = '('.$condition.') and text like :text';
  /* :text = '%'.$params['text'].'%' */
  $limit = -1;
}

Search through mysql works, but how to rewrite it through sphinx? And it's even better if you show how it's done in yii1 using the DGSphinxSearch extension.
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
Puma Thailand, 2016-12-20
@v3shin

What kind of tin do you have, use sphinxql

D
davidnum95, 2016-12-20
@davidnum95

What does it mean to rewrite through sphinx and why is it needed?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question