Skip to main content

Toponimo bakoitzeko ahozko eta idatzizko lekukotasun kopuruak jaso

<?php

$result = db_query('SELECT nid FROM node WHERE type = "toponimo"');
while($node = db_fetch_object($result)){
kopurua_jaso($node->nid);
}

function kopurua_jaso($pnid){
db_query('UPDATE toponimo SET ahozko_kop = (SELECT COUNT(*) FROM node_relations r LEFT JOIN content_type_lekukotasun l ON r.nid = l.nid WHERE r.type IN (527, 529, 528, 530) AND r.pnid = %d AND l.field_iturri_value = 0) WHERE nid = %d', $pnid, $pnid);
db_query('UPDATE toponimo SET idatzizko_kop = (SELECT COUNT(*) FROM node_relations r LEFT JOIN content_type_lekukotasun l ON r.nid = l.nid WHERE r.type IN (527, 529, 528, 530) AND r.pnid = %d AND l.field_iturri_value = 1) WHERE nid = %d', $pnid, $pnid);
}
?>