Skip to content

Commit

Permalink
1.6
Browse files Browse the repository at this point in the history
* [*] rt_DeleteIndex() теперь больше не приводит значение к типу INT
* [+] rt_DeleteIndexMatch() метод для удаления по текстовому полю
  • Loading branch information
KarelWintersky committed Oct 28, 2020
1 parent 7122aab commit 7499126
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 7 deletions.
25 changes: 21 additions & 4 deletions interfaces/SphinxToolkitFoolzInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ public static function rt_UpdateIndex(string $index_name, array $updateset);

/**
* Замещает (REPLACE) реалтайм-индекс по набору данных
* с созданием коннекшена "сейчас"
*
* @param string $index_name
* @param array $updateset
Expand All @@ -69,12 +68,15 @@ public static function rt_UpdateIndex(string $index_name, array $updateset);
public static function rt_ReplaceIndex(string $index_name, array $updateset);

/**
* Удаляет строку реалтайм-индекса
* с созданием коннекшена "сейчас"
* Удаляет строку реалтайм-индекса по значению нестрокового поля.
*
* @todo: при передаче параметра требуется его приведение к типу поля. Для поля 'id' это тип INT.
*
* В случае multi-valued атрибута нужно удалять строки для каждого значения атрибута.
*
* @param string $index_name -- индекс
* @param string $field -- поле для поиска индекса
* @param null $field_value -- значение для поиска индекса (важно: приводится к INTEGER)
* @param null $field_value -- значение для поиска индекса
* @return ResultSetInterface|null
*
* @throws DatabaseException
Expand All @@ -83,6 +85,21 @@ public static function rt_ReplaceIndex(string $index_name, array $updateset);
*/
public static function rt_DeleteIndex(string $index_name, string $field, $field_value = null);

/**
* Удаляет строку реалтайм-индекса по значению текстового поля, например '@title поликлиника'
* ВАЖНО: пустое значение поля $field_value удалит ВСЕ строки индекса
*
* @param string $index_name -- индекс
* @param string $field -- поле для поиска индекса
* @param string $field_value -- значение для поиска индекса (важно: тип значения должен совпадать)
* @return ResultSetInterface|null
*
* @throws DatabaseException
* @throws ConnectionException
* @throws SphinxQLException
*/
public static function rt_DeleteIndexMatch(string $index_name, string $field, $field_value = '');

/**
* Делает truncate index с реконфигурацией по умолчанию
*
Expand Down
21 changes: 18 additions & 3 deletions src/SphinxToolkit.php
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,21 @@ public static function rt_DeleteIndex(string $index_name, string $field, $field_
return self::createInstance()
->delete()
->from($index_name)
->where($field, '=', (int)$field_value)
->where($field, '=', $field_value)
->execute();
}

/**
* @inheritDoc
*/
public static function rt_DeleteIndexMatch(string $index_name, string $field, $field_value = '')
{
if (is_null($field_value)) return null;

return self::createInstance()
->delete()
->from($index_name)
->match($field, $field_value)
->execute();
}

Expand Down Expand Up @@ -530,8 +544,9 @@ private static function internal_ReplaceIndex(string $index_name, array $updates
->set($updateset)
->execute();
}





}

# -eof-

0 comments on commit 7499126

Please sign in to comment.