Пример #1
0
 /**
  * Delete the records without updating the parent info. It is used when deleting a whole channel and it's children need to be removed
  * @param array $childrenIds - list of node ids
  */
 public function deleteChildren($childrenIds)
 {
     //existing attach data
     $attachdata = vB::getDbAssertor()->getColumn('vBForum:attach', 'filedataid', array('nodeid' => $childrenIds), false, 'nodeid');
     //the number of times an attachment is used in the list of nodes
     $refcounts = array_count_values($attachdata);
     //the individual existing filedata records
     $filedata = vB::getDbAssertor()->getColumn('filedata', 'refcount', array('filedataid' => array_keys($refcounts)), false, 'filedataid');
     foreach ($filedata as $filedataid => $nr) {
         //the new value of the existing refcount
         $refCount = max($nr - $refcounts[$filedataid], 0);
         $this->assertor->update("vBForum:filedata", array('refcount' => $refCount), array('filedataid' => $filedataid));
     }
     //delete the main tables
     parent::deleteChildren($childrenIds);
 }
Пример #2
0
 /**
  * Delete the records without updating the parent info. It is used when deleting a whole channel and it's children need to be removed
  * @param array $childrenIds - list of node ids
  */
 public function deleteChildren($childrenIds)
 {
     foreach ($childrenIds as $photoId) {
         $fileDataRecord = $this->fetchFileDataRecord($photoId);
         $refCount = $fileDataRecord["refcount"] - 1;
         $data = array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_UPDATE, vB_dB_Query::CONDITIONS_KEY => array('filedataid' => $fileDataRecord["filedataid"]), 'refcount' => $refCount);
         $this->assertor->assertQuery("vBForum:filedata", $data);
     }
     //delete the main tables
     parent::deleteChildren($childrenIds);
 }