|
|
@@ -3,8 +3,8 @@ declare(strict_types=1);
|
|
|
|
|
|
class FreshRSS_TagDAO extends Minz_ModelPdo {
|
|
|
|
|
|
- public function sqlIgnore(): string {
|
|
|
- return 'IGNORE';
|
|
|
+ public static function sqlIgnoreConflict(string $sql): string {
|
|
|
+ return str_replace('INSERT INTO ', 'INSERT IGNORE INTO ', $sql);
|
|
|
}
|
|
|
|
|
|
public function sqlResetSequence(): bool {
|
|
|
@@ -303,10 +303,9 @@ class FreshRSS_TagDAO extends Minz_ModelPdo {
|
|
|
|
|
|
public function tagEntry(int $id_tag, string $id_entry, bool $checked = true): bool {
|
|
|
if ($checked) {
|
|
|
- $ignore = $this->sqlIgnore();
|
|
|
- $sql = <<<SQL
|
|
|
- INSERT {$ignore} INTO `_entrytag`(id_tag, id_entry) VALUES(:id_tag, :id_entry)
|
|
|
- SQL;
|
|
|
+ $sql = static::sqlIgnoreConflict(<<<'SQL'
|
|
|
+ INSERT INTO `_entrytag`(id_tag, id_entry) VALUES(:id_tag, :id_entry)
|
|
|
+ SQL);
|
|
|
} else {
|
|
|
$sql = <<<'SQL'
|
|
|
DELETE FROM `_entrytag` WHERE id_tag=:id_tag AND id_entry=:id_entry
|
|
|
@@ -331,9 +330,8 @@ class FreshRSS_TagDAO extends Minz_ModelPdo {
|
|
|
*/
|
|
|
public function tagEntries(iterable $addLabels): int|false {
|
|
|
$hasValues = false;
|
|
|
- $ignore = $this->sqlIgnore();
|
|
|
- $sql = <<<SQL
|
|
|
- INSERT {$ignore} INTO `_entrytag`(id_tag, id_entry) VALUES
|
|
|
+ $sql = <<<'SQL'
|
|
|
+ INSERT INTO `_entrytag`(id_tag, id_entry) VALUES
|
|
|
SQL;
|
|
|
foreach ($addLabels as $addLabel) {
|
|
|
$id_tag = (int)($addLabel['id_tag'] ?? 0);
|
|
|
@@ -347,6 +345,7 @@ class FreshRSS_TagDAO extends Minz_ModelPdo {
|
|
|
if (!$hasValues) {
|
|
|
return false;
|
|
|
}
|
|
|
+ $sql = static::sqlIgnoreConflict($sql);
|
|
|
|
|
|
$affected = $this->pdo->exec($sql);
|
|
|
if ($affected !== false) {
|