Answer the question
In order to leave comments, you need to log in
How to write a request to Sphinx using yii-sphinx?
Good afternoon.
I have Sphinx 2.0.4 with this configuration:
source tickets
{
type = mysql
sql_host = db
sql_user = db_user
sql_pass = db_pass
sql_db = db_name
sql_port = 3306
sql_query_pre = SET NAMES utf8
sql_query_pre = SET CHARACTER SET utf8
sql_query = SELECT id, title, description, image_small, pay, created, slug, type, pay_period_id,currency_id \
city_id FROM ticket
sql_field_string = title
sql_field_string = description
sql_attr_string = slug
sql_attr_string = image_small
sql_attr_timestamp = created
sql_attr_uint = type
sql_attr_uint = pay
sql_attr_uint = user_id
sql_attr_uint = pay_period_id
sql_attr_uint = currency_id
sql_attr_uint = city_id
sql_attr_multi = uint tag_ids from query; SELECT ticket_id, tag_id FROM ticket_tag
}
$query = SphinxTicket::find();
$query->where(['type'=>$type]);
if($this->match){
$query->match($this->match);
}
if($this->pay_min) $query->andWhere(['>=','pay',$this->pay_min]);
if($this->pay_max) $query->andWhere(['<=','pay',$this->pay_max]);
SQLSTATE[42000]: Syntax error or access violation: 1064 sphinxql: syntax error, unexpected '(', expecting IDENT (or 5 other tokens) near '((`type`=1) AND (`pay` >= '1000')) AND (`pay` <= '100000') LIMIT 2; SHOW META'
The SQL being executed was: SELECT * FROM `tickets_index` WHERE ((`type`=1) AND (`pay` >= '1000')) AND (`pay` <= '100000') LIMIT 2; SHOW META
Answer the question
In order to leave comments, you need to log in
Actually the problem was in Sphinx version. After updating to 2.2.9, both queries with brackets and queries that directly access the id field began to work (previously only @id worked),
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question