Add function for getting tags by base name, log base edits for tags in

NodaLogEdit
This commit is contained in:
Joshua Ramon Enslin 2021-05-26 22:36:02 +02:00
parent a4f24e5478
commit bc3f2a94d6
Signed by: jrenslin
GPG Key ID: 46016F84501B70AE
2 changed files with 46 additions and 0 deletions

View File

@ -241,6 +241,36 @@ final class NodaIDGetter {
} }
/**
* Returns tag ID by entry in tag translations table.
*
* @param MDMysqli $mysqli_noda Database connection.
* @param string $name Name of the tag to search for.
*
* @return integer
*/
public static function getTagIDByBaseName(MDMysqli $mysqli_noda, string $name):int {
if (empty($name)) return 0;
$tagByBaseNameResult = $mysqli_noda->query_by_stmt("
SELECT `tag_id`
FROM `tag_name`
WHERE `tag_name` = ?
LIMIT 2", "s", $name);
if ($tagByBaseData = $tagByBaseNameResult->fetch_row()) {
$output = $tagByBaseData[0];
}
else $output = 0;
$tagByBaseNameResult->close();
$tagByBaseNameResult = null;
return $output;
}
/** /**
* Returns tag ID by entry in tag translations table. * Returns tag ID by entry in tag translations table.
* *

View File

@ -87,6 +87,22 @@ final class NodaLogEdit {
$insertStmt->close(); $insertStmt->close();
$insertStmt = null; $insertStmt = null;
// Update the main tag table, except for edits to the base,
// as these have built-in updating and updating in this case
// would be superfluous.
if ($section !== 'base') {
$updateStmt = $mysqli_noda->do_prepare("UPDATE `tag`
SET `tag_erfasst_am` = NOW(),
`tag_erfasst_von` = ?
WHERE `tag_id` = ?");
$updateStmt->bind_param("si", $user_name, $tag_id);
$updateStmt->execute();
$updateStmt->close();
$updateStmt = null;
}
} }
/** /**