count-null-parent-ids-w-children.php

Count information objects missing parent IDs that have descendant records - Dan Gillean, 03/27/2018 02:50 PM

Download (597 Bytes)

 
1
<?php
2

    
3
print "Counting information objects with null as parent and with children...\n";
4

    
5
$criteria = new Criteria;
6
$criteria->add(QubitInformationObject::PARENT_ID, null, Criteria::ISNULL);
7

    
8
$result = QubitInformationObject::get($criteria);
9

    
10
$count = 0;
11

    
12
foreach($result as $io)
13
{
14
  if ($io->id != QubitInformationObject::ROOT_ID)
15
  {
16
    $c2 = new Criteria;
17
    $c2->add(QubitInformationObject::PARENT_ID, $io->id);
18

    
19
    $r2 = QubitInformationObject::get($c2);
20
    if (count($r2))
21
    {
22
      $count = $count + 1;
23
    }
24
  }
25
}
26

    
27
print "Counted ". $count ." information objects meeting criteria.\n";