15 private static bool $isAlreadyPlanned =
false;
17 public static function indexInBackground():
void
19 if (self::$isAlreadyPlanned)
24 self::$isAlreadyPlanned =
true;
29 public static function prepareSearchString(
string $searchString):
string
31 $searchString = Content::prepareStringToken($searchString);
32 $searchString = Helper::matchAgainstWildcard($searchString);
37 public static function deleteByFilter(array $filter):
void
40 $sqlHelper = $connection->getSqlHelper();
41 $indexTable = $sqlHelper->quote(static::getTableName());
42 $baseTable = $sqlHelper->quote(static::getBaseDataClass()::getTableName());
43 $indexTablePrimary = $sqlHelper->quote(static::getEntity()->getPrimary());
44 $baseTablePrimary = $sqlHelper->quote(static::getBaseDataClass()::getEntity()->getPrimary());
45 $whereStatement = Query::buildFilterSql(static::getBaseDataClass()::getEntity(), $filter);
47 if ($connection->getType() ==
'mysql')
52 INNER JOIN {$baseTable}
53 ON {$indexTable}.{$indexTablePrimary} = {$baseTable}.{$baseTablePrimary}
54 WHERE {$whereStatement};
57 elseif ($connection->getType() ==
'pgsql')
60 DELETE FROM {$indexTable}
63 {$indexTable}.{$indexTablePrimary} = {$baseTable}.{$baseTablePrimary}
68 $connection->queryExecute($sql);
71 public static function updateIndexStatus(array $ids,
bool $status =
true):
void
79 $sqlHelper = $connection->getSqlHelper();
80 $baseTable = $sqlHelper->quote(static::getBaseDataClass()::getTableName());
81 $baseTablePrimary = $sqlHelper->quote(static::getBaseDataClass()::getEntity()->getPrimary());
82 $implodeIds = implode(
',', $ids);
83 $statusString = $status ?
'Y' :
'N';
87 SET IS_INDEXED = '{$statusString}'
88 WHERE {$baseTablePrimary} IN ({$implodeIds});
91 $connection->queryExecute($sql);
94 private static function runIndex():
void
97 self::$isAlreadyPlanned =
false;
103 abstract protected static function getBaseDataClass(): string;
105 abstract public static function index(): void;
static getConnection($name="")
trait MultiplyInsertTrait