static function assignSectionToSubTree($nodeID, $sectionID, $oldSectionID = false)
 {
     $db = eZDB::instance();
     $node = eZContentObjectTreeNode::fetch($nodeID);
     $nodePath = $node->attribute('path_string');
     $sectionID = (int) $sectionID;
     $pathString = " path_string like '{$nodePath}%' AND ";
     // fetch the object id's which needs to be updated
     $objectIDArray = $db->arrayQuery("SELECT\n                                                   ezcontentobject.id\n                                            FROM\n                                                   ezcontentobject_tree, ezcontentobject\n                                            WHERE\n                                                  {$pathString}\n                                                  ezcontentobject_tree.contentobject_id=ezcontentobject.id AND\n                                                  ezcontentobject_tree.main_node_id=ezcontentobject_tree.node_id");
     if (count($objectIDArray) == 0) {
         return;
     }
     // Who assigns which section at which node should be logged.
     $section = eZSection::fetch($sectionID);
     $object = $node->object();
     eZAudit::writeAudit('section-assign', array('Section ID' => $sectionID, 'Section name' => $section->attribute('name'), 'Node ID' => $nodeID, 'Content object ID' => $object->attribute('id'), 'Content object name' => $object->attribute('name'), 'Comment' => 'Assigned a section to the current node and all child objects: eZContentObjectTreeNode::assignSectionToSubTree()'));
     $objectSimpleIDArray = array();
     foreach ($objectIDArray as $objectID) {
         $objectSimpleIDArray[] = $objectID['id'];
     }
     $filterPart = '';
     if ($oldSectionID !== false) {
         $oldSectionID = (int) $oldSectionID;
         $filterPart = " section_id = '{$oldSectionID}' and ";
     }
     $db->begin();
     foreach (array_chunk($objectSimpleIDArray, 100) as $pagedObjectIDs) {
         $db->query("UPDATE ezcontentobject SET section_id='{$sectionID}' WHERE {$filterPart} " . $db->generateSQLINStatement($pagedObjectIDs, 'id', false, true, 'int'));
         eZSearch::updateObjectsSection($pagedObjectIDs, $sectionID);
     }
     $db->commit();
     // clear caches for updated objects
     eZContentObject::clearCache($objectSimpleIDArray);
 }