0

I use yii 1 and this extension All works fine, but I need some advanced settings. Table good has filed good_code. And in this field data stored like

  1. 00-00000361
  2. 00000006309

So I need when user type 361 (which relate to the first good) or 6309(second good) sphinx find this good. For now only when I type full code - the good will find. How can I do that?

YuriiChmil
  • 441
  • 1
  • 5
  • 18

1 Answers1

0

Sounds like you have a string column, you could cast it to a interger and then allow that to be indexed.

Something like

sql_query = SELECT * FROM id, title, \ 
  CAST(REPLACE('-','',good_code) AS unsigned) AS good_code \
  FROM ... 

also adds a REPLACE to rmove the hyphens because that would upset a plain string to number conversion.

(sphinx would turn the integer back to simple string and index it as the raw number)

(May want to do something similar in a query, so if user enters 00000006309 it would still match)

barryhunter
  • 20,886
  • 3
  • 30
  • 43