Remove documents

@param  mixed $criteria
@return mixed
429768
public function remove($criteria) {

        $sql = 'DELETE FROM '.$this->name.' WHERE document_criteria("'.$this->database->registerCriteriaFunction($criteria).'", document)';

        return $this->database->connection->exec($sql);
    }
436572
public function delete(array $criteria = [], array $options = []) {
		return $this->getAdapter()->remove(
			$this->getTableName(),
			$criteria,
			$options
		);
	}
168619
private function parseCriteria(array $criteria)
    {
        $out = '';
        if (!empty($criteria)) {
            $conditions = [];
            foreach ($criteria as $field => $value) {
                if (is_array($value)) {
                    $values = array_map(function($value) { return $this->connection->quote($value); }, $value);
                    $conditions[] = sprintf('%s IN (%s)', $field, implode(', ', $values));
                } else {
                    $operator = '=';
                    $ops = ['<>', '<', '>', '<=', '>='];
                    foreach ($ops as $op) {
                        if (false !== strpos($value, $op)) {
                            $operator = $op;
                            $value = str_replace(sprintf('%s ', $op), '', $value);
                            break;
                        }
                    }
                    $conditions[] = sprintf('%s %s %s', $field, $operator, $this->connection->quote($value));
                }
            }
            $out = sprintf(' WHERE %s', implode(' AND ', $conditions));
        }
        return $out;
    }
149864
public static function count($criteria = array())
    {
        self::processCriteriaWithType($criteria);
        $count = self::connection()->count(self::collectionName(), $criteria);
        return $count;
    }
678039
public function findOneBy(array $criteria)
    {
        $query = $this->createQueryBuilder($criteria);
        if (!($object = $this->getOneOrNullResultFromQueryBuilder($query))) {
            $this->throwException('The resource was not found', 'not-found');
        }
        return $object;
    }
1246482
public function scanLocations(array $criteria)
    {
        $uris = $this->locations->map(function ($location) use ($criteria) {
            /** @var Location $location */
            return $location->getURI($criteria);
        })->filter(function ($uri) {
            return false !== $uri;
        });
        
        // Fall back for absolute paths on current filesystem.
        if ($uris->isEmpty()) {
            foreach ($criteria as $criterion) {
                if (file_exists($criterion)) {
                    return $criterion;
                }
            }
        }

        return $uris->isEmpty() ? false : $uris->first();
    }
427232
public function findBy(array $criteria)
    {
        $found = [];
        foreach ($this->getCollection()->all() as $template) {
            foreach ($criteria as $criterium => $value) {
                $method = 'get'.ucfirst(strtolower($criterium));
                if (!method_exists($template, $method)) {
                    continue;
                }
                if ($template->$method() !== $value) {
                    continue 2;
                }
            }

            $found[] = $template;
        }

        return $found;
    }
796965
public function select($criteria)
    {
        $selected = [];
        
        if (is_array($criteria)) {
            foreach ($this as $member) {
                foreach ($criteria as $propName => $value) {
                    if ($member->getProperty($propName) != $value) {
                        continue;
                    }
                    $selected[] = $member;
                }
            }
        } elseif ($criteria instanceof Closure) {
            foreach ($this as $member) {
                if ($criteria($member)) {
                    $selected[] = $member;
                };
            }
        }
        
        return new static($selected);
    }
615079
public function remove($documents)
    {
        if (!is_array($documents)) {
            $documents = array($documents);
        }

        $remove =& Archive::getByRef($this, 'remove', array());
        foreach ($documents as $document) {
            $remove[] = $document;
        }
    }
1179061
public static function findByCriteria(array $criteria): ?Model\Collection
    {
        try {
            list($columns, $values, $options) = static::parseCriteria($criteria);
        } catch (NoTagsException $e) {
            return null;
        }

        if (\count($columns) < 1) {
            return static::findAll($options);
        }

        return static::findBy($columns, $values, $options);
    }
649035
public function delete(array $criteria = [])
    {
        $this->viewCheck(__FUNCTION__);

        $query = $this->buildDelete($criteria);

        $old = clone $this;
        if (!$this->beforeDelete($criteria))
            return false;

        if ($result = $this->run($query, $criteria))
            $this->next();

        if (!$this->afterDelete($old))
            return false;

        return $result;
    }
1261356
public function remove(array $criteria = [], array $options = [])
    {
        $this->createChunksIndex();

        $matchingFiles = parent::find($criteria, ['_id' => 1]);
        $ids = [];
        foreach ($matchingFiles as $file) {
            $ids[] = $file['_id'];
        }
        $this->chunks->remove(['files_id' => ['$in' => $ids]], ['justOne' => false] + $options);
        return parent::remove(['_id' => ['$in' => $ids]], ['justOne' => false] + $options);
    }
430129
public function getGroupBy(Criteria $criteria)
    {
        $groupBy = $criteria->getGroupByColumns();

        if ($groupBy) {
            // check if all selected columns are groupBy'ed.
            $selected = $this->getPlainSelectedColumns($criteria);
            $asSelects = $criteria->getAsColumns();

            foreach ($selected as $colName) {
                if (!in_array($colName, $groupBy)) {

                    // is a alias there that is grouped?
                    if ($alias = array_search($colName, $asSelects)) {
                        if (in_array($alias, $groupBy)) {
                            continue; //yes, alias is selected.
                        }
                    }
                    $groupBy[] = $colName;
                }
            }

            if ($groupBy) {
                return ' GROUP BY ' . implode(',', $groupBy);
            }
        }

        return '';
    }
908075
public function delete($collection, array $criteria, $multi = TRUE)
	{
		$conds = $this->preprocessor->processCondition($criteria);

		$result = (int) $this->queryAdapter->delete($collection, $conds, $multi);

		$this->onQuery($collection, 'delete', ['criteria' => $conds, 'multi' => $multi], $result);

		return $result;
	}
1229984
public function matching(Criteria $criteria)
    {
        $persister = $this->_em->getUnitOfWork()->getEntityPersister($this->_entityName);

        return new LazyCriteriaCollection($persister, $criteria);
    }
299426
public function getURIs(array $criteria): URIs
    {
        $uris = new URIs();

        foreach ($this->extensions as $extension) {
            $finder = new Finder();

            try {
                $finder->files()
                    ->name($this->getNamePattern($criteria, $extension))
                    ->in($this->getPathPattern($this->getRelativePath($criteria)));
                foreach ($finder as $file) {
                    /** @var SplFileInfo $file */
                    $uris->add($file->getPathname());
                }
            } catch (Exception $exception) {
                // Fail silently;
            }
        }

        return $uris;
    }
462466
public function delete(string $table, array $criteria = []): int {
		
		// this one is like the insertSingle above in that it uses its parameters
		// to build a query.  unlike that one, we execute it here and return the
		// number of deleted rows.
		
		$statement = "DELETE FROM $table";
		
		if (sizeof($criteria) > 0) {
			
			// we want to take our column names and turn them into a string
			// like x=? AND y=? AND z=? so that we can tack it onto our
			// $statement
			
			$columns = array_keys($criteria);
			array_walk($columns, function(&$x) {
				$x = sprintf("%s%s%s = ?", $this->columnPrefix, $x, $this->columnSuffix);
			});
			$statement .= " WHERE " . join(" AND ", $columns);
		}
		
		$bindings = array_values($criteria);
		
		try {
			return $this->dbConn->fetchAffected($statement, $bindings);
		} catch (\PDOException $pdoException) {
			throw $this->prepareDatabaseException($pdoException, $statement, $bindings);
		}
	}