Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Commit 7499126

Browse files
1.6
* [*] rt_DeleteIndex() теперь больше не приводит значение к типу INT * [+] rt_DeleteIndexMatch() метод для удаления по текстовому полю
1 parent 7122aab commit 7499126

File tree

2 files changed

+39
-7
lines changed

2 files changed

+39
-7
lines changed

interfaces/SphinxToolkitFoolzInterface.php

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ public static function rt_UpdateIndex(string $index_name, array $updateset);
5656

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

7170
/**
72-
* Удаляет строку реалтайм-индекса
73-
* с созданием коннекшена "сейчас"
71+
* Удаляет строку реалтайм-индекса по значению нестрокового поля.
72+
*
73+
* @todo: при передаче параметра требуется его приведение к типу поля. Для поля 'id' это тип INT.
74+
*
75+
* В случае multi-valued атрибута нужно удалять строки для каждого значения атрибута.
7476
*
7577
* @param string $index_name -- индекс
7678
* @param string $field -- поле для поиска индекса
77-
* @param null $field_value -- значение для поиска индекса (важно: приводится к INTEGER)
79+
* @param null $field_value -- значение для поиска индекса
7880
* @return ResultSetInterface|null
7981
*
8082
* @throws DatabaseException
@@ -83,6 +85,21 @@ public static function rt_ReplaceIndex(string $index_name, array $updateset);
8385
*/
8486
public static function rt_DeleteIndex(string $index_name, string $field, $field_value = null);
8587

88+
/**
89+
* Удаляет строку реалтайм-индекса по значению текстового поля, например '@title поликлиника'
90+
* ВАЖНО: пустое значение поля $field_value удалит ВСЕ строки индекса
91+
*
92+
* @param string $index_name -- индекс
93+
* @param string $field -- поле для поиска индекса
94+
* @param string $field_value -- значение для поиска индекса (важно: тип значения должен совпадать)
95+
* @return ResultSetInterface|null
96+
*
97+
* @throws DatabaseException
98+
* @throws ConnectionException
99+
* @throws SphinxQLException
100+
*/
101+
public static function rt_DeleteIndexMatch(string $index_name, string $field, $field_value = '');
102+
86103
/**
87104
* Делает truncate index с реконфигурацией по умолчанию
88105
*

src/SphinxToolkit.php

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,21 @@ public static function rt_DeleteIndex(string $index_name, string $field, $field_
430430
return self::createInstance()
431431
->delete()
432432
->from($index_name)
433-
->where($field, '=', (int)$field_value)
433+
->where($field, '=', $field_value)
434+
->execute();
435+
}
436+
437+
/**
438+
* @inheritDoc
439+
*/
440+
public static function rt_DeleteIndexMatch(string $index_name, string $field, $field_value = '')
441+
{
442+
if (is_null($field_value)) return null;
443+
444+
return self::createInstance()
445+
->delete()
446+
->from($index_name)
447+
->match($field, $field_value)
434448
->execute();
435449
}
436450

@@ -530,8 +544,9 @@ private static function internal_ReplaceIndex(string $index_name, array $updates
530544
->set($updateset)
531545
->execute();
532546
}
533-
534-
547+
548+
549+
535550
}
536551

537552
# -eof-

0 commit comments

Comments
 (0)