Sphinx field_weights

master
Vitaliy Filippov 2013-07-17 21:07:19 +00:00
parent aee6a019a3
commit f3c4baefe3
1 changed files with 11 additions and 0 deletions

View File

@ -400,6 +400,7 @@ class DatabaseMysql implements Database
*
* Sphinx Search extensions:
* 'WITHIN GROUP ORDER BY' => array($orderby_field => 'ASC')
* 'FIELD_WEIGHTS' => array('field' => <weight>, ...)
*/
function select_builder($tables, $fields, $where, $options = NULL)
{
@ -446,6 +447,16 @@ class DatabaseMysql implements Database
$sql .= " WITHIN GROUP ORDER BY ".$this->order_option($options['WITHIN GROUP ORDER BY']);
}
$sql .= $this->limit_option($options);
if (!empty($options['FIELD_WEIGHTS']))
{
// Sphinx Search extension
$weights = array();
foreach ($options['FIELD_WEIGHTS'] as $f => $w)
{
$weights[] = "`$f`=$w";
}
$sql .= " OPTION field_weights=(".implode(', ', $weights).")";
}
if (isset($options['FOR UPDATE']))
$sql .= ' FOR UPDATE';
elseif (isset($options['LOCK IN SHARE MODE']))