示例#1
0
文件: Row.php 项目: Doluci/tomatocart
 /**
  * Helper function to test if two rows are equal.
  * 
  * Two rows are equal 
  * - if they have exactly the same columns / details
  * - if they have a subDataTable associated, then we check that both of them are the same.
  * 
  * @param Piwik_DataTable_Row row1 to compare
  * @param Piwik_DataTable_Row row2 to compare
  * 
  * @return bool
  */
 public static function isEqual(Piwik_DataTable_Row $row1, Piwik_DataTable_Row $row2)
 {
     //same columns
     $cols1 = $row1->getColumns();
     $cols2 = $row2->getColumns();
     uksort($cols1, 'strnatcasecmp');
     uksort($cols2, 'strnatcasecmp');
     if ($cols1 != $cols2) {
         return false;
     }
     $dets1 = $row1->getDetails();
     $dets2 = $row2->getDetails();
     ksort($dets1);
     ksort($dets2);
     // same details
     if ($dets1 != $dets2) {
         return false;
     }
     // either both are null
     // or both have a value
     if (!(is_null($row1->getIdSubDataTable()) && is_null($row2->getIdSubDataTable()))) {
         $subtable1 = Piwik_DataTable_Manager::getInstance()->getTable($row1->getIdSubDataTable());
         $subtable2 = Piwik_DataTable_Manager::getInstance()->getTable($row2->getIdSubDataTable());
         if (!Piwik_DataTable::isEqual($subtable1, $subtable2)) {
             return false;
         }
     }
     return true;
 }