Page 1 of 1

Add new tag to all entries of certain category

Posted: Thu Jul 29, 2010 2:03 am
by Matthias
Hi,

is it possible to add a new additional tag to all entries of certain category via MySQL query? Database structure does not seem so?!

thanks

Re: Add new tag to all entries of certain category

Posted: Thu Jul 29, 2010 1:03 pm
by garvinhicking
Hi!

Of course, you can do anything to date stored in serendipity with straight SQL. :-)

However you would need a temporary storage, and its much easier to perform the query with some PHP glue:

Code: Select all

<?php
include 'serendipity_config.inc.php';

$newtag = "Inception";
$entries = serendipity_db_query("SELECT id FROM {$serendipity['dbPrefix']}entries");
foreach($entries AS $entry) {
  serendipity_db_query("INSERT INTO {$serendipity['dbPrefix']}entrytags (entryid, tag) VALUES (" . $entry['id'] . ", '" . serendipity_db_escape_string($newtag) . "')");
}
HTH,
Garvin