Piwik\DataTable::deleteRows PHP Method

deleteRows() public method

Deletes a set of rows by ID.
public deleteRows ( array $rowIds )
$rowIds array The list of row IDs to delete.
    public function deleteRows(array $rowIds)
    {
        foreach ($rowIds as $key) {
            $this->deleteRow($key);
        }
    }

Usage Example

Beispiel #1
0
 /**
  * @param DataTable $table
  * @param int $idSite
  * @param string $period
  * @param string $date
  * @return mixed
  */
 protected function removeHoursInFuture($table, $idSite, $period, $date)
 {
     $site = new Site($idSite);
     if ($period == 'day' && ($date == 'today' || $date == Date::factory('now', $site->getTimezone())->toString())) {
         $currentHour = Date::factory('now', $site->getTimezone())->toString('G');
         // If no data for today, this is an exception to the API output rule, as we normally return nothing:
         // we shall return all hours of the day, with nb_visits = 0
         if ($table->getRowsCount() == 0) {
             for ($hour = 0; $hour <= $currentHour; $hour++) {
                 $table->addRowFromSimpleArray(array('label' => $hour, 'nb_visits' => 0));
             }
             return $table;
         }
         $idsToDelete = array();
         foreach ($table->getRows() as $id => $row) {
             $hour = $row->getColumn('label');
             if ($hour > $currentHour) {
                 $idsToDelete[] = $id;
             }
         }
         $table->deleteRows($idsToDelete);
     }
     return $table;
 }
All Usage Examples Of Piwik\DataTable::deleteRows