Add new tag to all entries of certain category

Random stuff about serendipity. Discussion, Questions, Paraphernalia.
Post Reply
Matthias
Regular
Posts: 47
Joined: Wed Mar 01, 2006 4:33 pm
Contact:

Add new tag to all entries of certain category

Post 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
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Add new tag to all entries of certain category

Post 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
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Post Reply