Skip to content
Snippets Groups Projects
Commit e1400c21 authored by Tamilselvan Sekar's avatar Tamilselvan Sekar Committed by Thijs Kinkhorst
Browse files

feat(pdo): add removeEntry method to clear expired metadata

parent e1f713f7
Branches
Tags
No related merge requests found
...@@ -255,6 +255,31 @@ class MetaDataStorageHandlerPdo extends MetaDataStorageSource ...@@ -255,6 +255,31 @@ class MetaDataStorageHandlerPdo extends MetaDataStorageSource
} }
/**
* Remove metadata from the configured database
*
* @param string $entityId The entityId we are removing.
* @param string $set The set to remove the metadata from.
*
* @return bool True/False if entry was successfully deleted
*/
public function removeEntry(string $entityId, string $set): bool
{
if (!in_array($set, $this->supportedSets, true)) {
return false;
}
$tableName = $this->getTableName($set);
$rows = $this->db->write(
"DELETE FROM $tableName WHERE entity_id = :entity_id",
['entity_id' => $entityId]
);
return $rows === 1;
}
/** /**
* Replace the -'s to an _ in table names for Metadata sets * Replace the -'s to an _ in table names for Metadata sets
* since SQL does not allow a - in a table name. * since SQL does not allow a - in a table name.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment