Purge all numeric and blob archives with the given IDs from the database.
@param array $idArchivesToDelete
@param Date $dateStart
@param string $reason
@return int
187196
protected function purge(array $idArchivesToDelete, Date $dateStart, $reason)
    {
        $deletedRowCount = 0;
        if (!empty($idArchivesToDelete)) {
            $deletedRowCount = $this->deleteArchiveIds($dateStart, $idArchivesToDelete);

            $this->logger->info(
                "Deleted {count} rows in archive tables (numeric + blob) for {reason} for {date}.",
                array(
                    'count' => $deletedRowCount,
                    'date' => $dateStart,
                    'reason' => $reason
                )
            );

            $this->logger->debug("[Deleted IDs: {deletedIds}]", array(
                'deletedIds' => implode(',', $idArchivesToDelete)
            ));
        } else {
            $this->logger->debug(
                "No archives for {reason} found in archive numeric table for {date}.",
                array('date' => $dateStart, 'reason' => $reason)
            );
        }

        return $deletedRowCount;
    }
511454
public function delete($date)
    {
        $path = $this->getLogPath($date);

        // @codeCoverageIgnoreStart
        if ( ! $this->filesystem->delete($path)) {
            throw new FilesystemException('There was an error deleting the log.');
        }
        // @codeCoverageIgnoreEnd

        return true;
    }
593048
public function removeChildren($from, $to = null, $forceDelete = false)
    {
        if (!is_numeric($from) || (!is_null($to) && !is_numeric($to))) {
            throw new \InvalidArgumentException('`from` and `to` are the position boundaries. They must be of type int.');
        }

        if ($this->exists) {
            $action = ($forceDelete === true ? 'forceDelete' : 'delete');

            $this->children([$from, $to])->$action();
        }

        return $this;
    }
1098370
public int deleteByRootComponentIdAndPermission(DbSession dbSession, long rootComponentId, String permission) {
    return mapper(dbSession).deleteByRootComponentIdAndPermission(rootComponentId, permission);
  }
857830
private function sortByStartDate(Period $interval1, Period $interval2): int
    {
        return $interval1->getStartDate() <=> $interval2->getStartDate();
    }
1043303
public function getRegion($idSite, $period, $date, $segment = false)
    {
        $dataTable = $this->getDataTable(Archiver::REGION_RECORD_NAME, $idSite, $period, $date, $segment);

        $separator = Archiver::LOCATION_SEPARATOR;
        $unk = Visit::UNKNOWN_CODE;

        $dataTables = [$dataTable];

        if ($dataTable instanceof DataTable\Map) {
            $dataTables = $dataTable->getDataTables();
        }

        foreach ($dataTables as $dt) {
            $archiveDate = $dt->getMetadata(DataTable::ARCHIVED_DATE_METADATA_NAME);

            // convert fips region codes to iso if required
            if ($this->shouldRegionCodesBeConvertedToIso($archiveDate, $date, $period)) {
                $dt->filter('GroupBy', array(
                    'label',
                    function ($label) use ($separator, $unk) {
                        $regionCode = getElementFromStringArray($label, $separator, 0, '');
                        $countryCode = getElementFromStringArray($label, $separator, 1, '');

                        list($countryCode, $regionCode) = GeoIp2::convertRegionCodeToIso($countryCode,
                            $regionCode, true);

                        $splitLabel = explode($separator, $label);

                        if (isset($splitLabel[0])) {
                            $splitLabel[0] = $regionCode;
                        }

                        if (isset($splitLabel[1])) {
                            $splitLabel[1] = strtolower($countryCode);
                        }

                        return implode($separator, $splitLabel);
                    }
                ));
            } else if ($dt->getRowFromLabel('1|ti')) {
                $dt->filter('GroupBy', array(
                    'label',
                    function ($label) {
                        if ($label == '1|ti') {
                            return '14|cn';
                        }
                        return $label;
                    }
                ));
            }
        }

        $segments = array('regionCode', 'countryCode');
        $dataTable->filter('AddSegmentByLabel', array($segments, Archiver::LOCATION_SEPARATOR));

        // split the label and put the elements into the 'region' and 'country' metadata fields
        $dataTable->filter('ColumnCallbackAddMetadata',
            array('label', 'region', __NAMESPACE__ . '\getElementFromStringArray', array($separator, 0, $unk)));
        $dataTable->filter('ColumnCallbackAddMetadata',
            array('label', 'country', __NAMESPACE__ . '\getElementFromStringArray', array($separator, 1, $unk)));

        // add country name metadata
        $dataTable->filter('MetadataCallbackAddMetadata',
            array('country', 'country_name', __NAMESPACE__ . '\CountryTranslate', $applyToSummaryRow = false));

        // get the region name of each row and put it into the 'region_name' metadata
        $dataTable->filter('ColumnCallbackAddMetadata',
            array('label', 'region_name', __NAMESPACE__ . '\getRegionName', $params = null,
                  $applyToSummaryRow = false));

        // add the country flag as a url to the 'logo' metadata field
        $dataTable->filter('MetadataCallbackAddMetadata', array('country', 'logo', __NAMESPACE__ . '\getFlagFromCode'));

        // prettify the region label
        $dataTable->filter('ColumnCallbackReplace', array('label', __NAMESPACE__ . '\getPrettyRegionName'));

        $dataTable->queueFilter('ReplaceSummaryRowLabel');

        return $dataTable;
    }
331569
public function diffInDaysFiltered(Closure $callback, Time $dt = null, $abs = true)
         {
              $start = $this;
              $end = ($dt === null) ? static::now($this->tz) : $dt;
              $inverse = false;

              if ($end < $start) {
                    $start = $end;
                    $end = $this;
                    $inverse = true;
              }

              $period = new DatePeriod($start, new DateInterval('P1D'), $end);
              $days = array_filter(iterator_to_array($period), function (DateTime $date) use ($callback) {
                    return call_user_func($callback, Time::instance($date));
              });

              $diff = count($days);

              return $inverse && !$abs ? -$diff : $diff;
         }
814401
final Deferred<Object> delete(final byte[] key, final byte[][] qualifiers) {
    return client.delete(new DeleteRequest(table, key, FAMILY, qualifiers));
  }
343764
public function getListUserCountByRangeDate($types, $startDate = '', $endDate = '')
    {
        if (empty($types)) {
            return array();
        }
        $em = $this->getServiceManager()->get('doctrine.entitymanager.orm_default');

        $now = new \DateTime("now");
        // $now->format('Y-m-d') . ' 23:59:59';
        $startDateTime = \DateTime::createFromFormat('d/m/Y', $startDate);
        $endDateTime = \DateTime::createFromFormat('d/m/Y', $endDate);

        $rsm = new \Doctrine\ORM\Query\ResultSetMapping;

        $select = array();
        $i = 0;

        foreach ($types as $type) {
            switch ($type) {
                case 'validatedMembers':
                    $filter = "u.state IS NOT NULL";
                    break;
                case 'activeMembers':
                    $filter = "u.state=1";
                    break;
                case 'optin':
                    $filter = "u.optin=1";
                    break;
                case 'optinPartners':
                    $filter = "u.optin_partner=1";
                    break;
                case 'unregistered':
                    $filter = "u.state IS NULL";
                    break;
                case 'suspended':
                    $filter = "u.state=2";
                    break;
                default:
                case 'members':
                    $filter = "u.user_id";
                    break;
            }

            $rsm->addScalarResult('c'.$i, 'c'.$i);
            $select[] = 'SUM(CASE WHEN '.$filter.' THEN 1 ELSE 0 END) AS c'.$i;
            $rsm->addScalarResult('c'.$i.'_male', 'c'.$i.'_male');
            $select[] = 'SUM(CASE WHEN '.$filter.' AND (u.title=\'M\' OR u.title IS NULL) THEN 1 ELSE 0 END) AS c'.$i.'_male';
            $rsm->addScalarResult('c'.$i.'_female', 'c'.$i.'_female');
            $select[] = 'SUM(CASE WHEN '.$filter.' AND u.title=\'Me\' THEN 1 ELSE 0 END) AS c'.$i++.'_female';
        }

        if ($startDate != '' && $endDate != '') {
            $dateRange = "(u.created_at >='" . $startDateTime->format('Y-m-d') . " 0:0:0' AND u.created_at <= '" . $endDateTime->format('Y-m-d') . " 0:0:0')";
        } elseif ($startDate == '' && $endDate != '') {
            $dateRange = "u.created_at <= '" . $endDateTime->format('Y-m-d') . " 0:0:0'";
        } elseif ($startDate != '' && $endDate == '') {
            $dateRange = "u.created_at >='" . $startDateTime->format('Y-m-d') . " 0:0:0'";
        } else {
            $dateRange = "u.created_at IS NOT NULL";
        }
        $query = $em->createNativeQuery('
			SELECT '.implode(',', $select).' FROM user AS u
			WHERE ' . $dateRange, $rsm);
        return array_values($query->getSingleResult());
    }
638543
public void deleteCalendar(GoogleCalendar calendar) throws IOException {
        dao.calendars().delete(calendar.getId()).execute();
    }
723302
public static void recursiveDelete(final ServiceBundler services, final Session session, final IRI identifier,
            final String baseUrl) {
        final List<IRI> resources = services.getResourceService().get(identifier)
            .thenApply(res -> res.stream(LDP.PreferContainment).map(Quad::getObject).filter(IRI.class::isInstance)
                    .map(IRI.class::cast).collect(toList())).toCompletableFuture().join();
        resources.forEach(id -> recursiveDelete(services, session, id, baseUrl));
        resources.stream().parallel().map(id -> {
                final TrellisDataset immutable = TrellisDataset.createDataset();
                services.getAuditService().creation(id, session).stream()
                    .map(skolemizeQuads(services.getResourceService(), baseUrl)).forEachOrdered(immutable::add);

                return services.getResourceService().delete(Metadata.builder(id).interactionModel(LDP.Resource)
                        .container(identifier).build())
                    .thenCompose(future -> services.getResourceService().add(id, immutable.asDataset()))
                    .whenComplete((a, b) -> immutable.close())
                    .thenAccept(future -> services.getEventService().emit(new SimpleEvent(externalUrl(id, baseUrl),
                                session.getAgent(), asList(PROV.Activity, AS.Delete), singletonList(LDP.Resource))));
            })
            .map(CompletionStage::toCompletableFuture).forEach(CompletableFuture::join);
    }
838371
function getDeletedEmbedIDArray( $includeTrash = false )
    {
        $arr = array();
        if ( $this->deletedEmbeddedNodeIDArray )
            $arr['nodes'] = $this->deletedEmbeddedNodeIDArray;
        if ( $this->deletedEmbeddedObjectIDArray )
            $arr['objects'] = $this->deletedEmbeddedObjectIDArray;
        if ( $includeTrash && $this->thrashedEmbeddedObjectIDArray )
            $arr['trash'] = $this->thrashedEmbeddedObjectIDArray;
        return $arr;
    }
390157
public function getAll($idSite, $period, $date, $segment = false)
    {
        Piwik::checkUserHasViewAccess($idSite);

        $this->checkSingleSite($idSite, 'getAll');
        $dataTable = $this->getReferrerType($idSite, $period, $date, $segment, $typeReferrer = false, $idSubtable = false, $expanded = true);

        if ($dataTable instanceof DataTable\Map) {
            throw new Exception("Referrers.getAll with multiple sites or dates is not supported (yet).");
        }

        $dataTable = $dataTable->mergeSubtables($labelColumn = 'referer_type', $useMetadataColumn = true);
        $dataTable->queueFilter('ReplaceColumnNames');
        $dataTable->queueFilter('ReplaceSummaryRowLabel');

        return $dataTable;
    }
363599
@Override
	public int deleteAllAlerts() throws DatabaseException {
    	SqlPreparedStatementWrapper psDeleteAllAlerts = null;
        try {
        	psDeleteAllAlerts = DbSQL.getSingleton().getPreparedStatement("alert.ps.deleteall");
			return psDeleteAllAlerts.getPs().executeUpdate();
		} catch (SQLException e) {
			throw new DatabaseException(e);
		} finally {
			DbSQL.getSingleton().releasePreparedStatement(psDeleteAllAlerts);
		}
    }
242108
function purgeResource(resource, archive) {
        if (!resource.purge) { return true; }

        var criteria = resource.purge();
        var deferred = Q.defer();

        archive.bind(resource.name);
        archive[resource.name].remove(criteria, function (err, results) {
            err ? deferred.reject(err) : deferred.resolve(results);
        });
        return deferred.promise;
    }
1306043
public function removeReminders($starttime, $endtime, $all = false) {
		$starttime = sanitize_int($starttime);
		$endtime = sanitize_int($endtime);
		
		$options = array(
			'guid' => $this->guid,
			'annotation_names' => array('reminder'),
			'limit' => false
		);
		
		if (!$all) {
			$options['wheres'] = "CAST(v.string as SIGNED) BETWEEN {$starttime} AND {$endtime}";
		}
		
		return elgg_delete_annotations($options);
	}
1018355
public ODatabaseRecord delete(final ORID iRecord) {
    executeDeleteRecord(iRecord, -1, true, true, OPERATION_MODE.SYNCHRONOUS);
    return this;
  }