
Шпаргалка по работе с Nodes.
Удалить все node определенного типа из базы.
Не забудьте сделать бекап базы перед запуском этих функций.
Запускать эти функции удобно через блок Exucute PHP модуля Devel.
<?php
// Don't forget change 'content_type_art' to your type
$result = db_query('SELECT nid FROM {content_type_art}');
while ($row = db_fetch_array($result)) {
//This time limit is important, if it is removed the query will exceed the 30sec limit.
set_time_limit(5);
//delete node
node_delete($row['nid']);
}
?>Как обновить nodes. Этот код использовался мной, чтобы обновить вычисляемое поле Computed field для CCK для всех нодов. Так как это поле было мной добавлено уже после внесения данных.
<?php
// This query is used to load all the nids of a specific content type into an array. Change `node_content_profile' to the name of the
$query = 'SELECT nid FROM {content_type_art}';
$profilenidarray = array();
$profilenidarray = db_query($query);
// For each nid this will load and then save the node
while ($nodeID = db_fetch_array($profilenidarray)){
//This time limit is important, if it is removed the query will exceed the 30sec limit.
//set_time_limit(5);
$PNID = node_load($nodeID["nid"]);
node_save($PNID);
}
// Just so you know its done!
print 'done';
?>
Отправить новый комментарий