I F T B Q P ::

Il fait toujours beau quelque part
Syndiquer le contenu

node

How to delete nodes by type and clean up sequences | drupal.org

<?php

$node_types = array(
'xxxxxx', //update this string with the type of node you want to delete
'xxxxxx', //update this string with the type of node you want to delete and add any more lines you might need
);

$sql = 'SELECT nid FROM {node} WHERE type IN ('. implode(', ', array_fill(0, count($node_types), "'%s'")). ')';
$result = db_query($sql, $node_types);
while ($row = db_fetch_object($result)) {
node_delete($row->nid);
}

db_query("UPDATE sequences SET id = (SELECT MAX(nid) FROM {node}) WHERE name = '{node}_nid'");
db_query("UPDATE sequences SET id = (SELECT MAX(vid) FROM {node_revisions}) WHERE name = '{node}_revisions_vid'");

?>

Login or register to tag items