Returns the "DELETE FROM <table> [AS <alias>]" part of DELETE query.

@param Criteria $criteria
@param string   $tableName

@return string
559187
public function getDeleteFromClause($criteria, $tableName)
    {
        $sql = 'DELETE ';
        if ($queryComment = $criteria->getComment()) {
            $sql .= '/* ' . $queryComment . ' */ ';
        }
        if ($realTableName = $criteria->getTableForAlias($tableName)) {
            if ($this->useQuoteIdentifier()) {
                $realTableName = $this->quoteIdentifierTable($realTableName);
            }
            $sql .= $tableName . ' FROM ' . $realTableName . ' AS ' . $tableName;
        } else {
            if ($this->useQuoteIdentifier()) {
                $tableName = $this->quoteIdentifierTable($tableName);
            }
            $sql .= 'FROM ' . $tableName;
        }

        return $sql;
    }
958328
public function count($criteria=null)
	{
		$query=new CJoinQuery($this,$criteria);
		// ensure only one big join statement is used
		$this->_finder->baseLimited=false;
		$this->_finder->joinAll=true;
		$this->buildQuery($query);

		$query->limit=$query->offset=-1;

		if(!empty($criteria->group) || !empty($criteria->having))
		{
			$query->orders = array();
			$command=$query->createCommand($this->_builder);
			$sql=$command->getText();
			$sql="SELECT COUNT(*) FROM ({$sql}) sq";
			$command->setText($sql);
			$command->params=$query->params;
			return $command->queryScalar();
		}
		else
		{
			$select=is_array($criteria->select) ? implode(',',$criteria->select) : $criteria->select;
			if($select!=='*' && preg_match('/^count\s*\(/i',trim($select)))
				$query->selects=array($select);
			elseif(is_string($this->_table->primaryKey))
			{
				$prefix=$this->getColumnPrefix();
				$schema=$this->_builder->getSchema();
				$column=$prefix.$schema->quoteColumnName($this->_table->primaryKey);
				$query->selects=array("COUNT(DISTINCT $column)");
			}
			else
				$query->selects=array("COUNT(*)");

			$query->orders=$query->groups=$query->havings=array();
			$command=$query->createCommand($this->_builder);
			return $command->queryScalar();
		}
	}
1267877
public function dontSeeInDatabase( $table, $criteria = array() ) {
		$query = $this->_prepareQuery( $table, 'count(*)', $criteria );
		$this->debugSection( 'Query', $query );

		$suppress_errors = $this->_wpdb->suppress_errors( true );
		$res = $this->_wpdb->get_var( $query );
		$this->_wpdb->suppress_errors( $suppress_errors );

		if ( ! empty( $this->_wpdb->last_error ) ) {
			$this->fail( 'Database error: ' . $this->_wpdb->last_error );
			return;
		}

		$this->assertLessThan( 1, $res, 'Matching records found' );
	}
271592
public function matching(Criteria $criteria) {
		if(!$this->baseRepository instanceof Selectable) {
			throw new \LogicException('The base repository does not implement Selectable.');
		}
		return $this->baseRepository->matching($criteria);
	}
1009585
private function getLimitSql(Criteria $criteria)
    {
        $limit  = $criteria->getMaxResults();
        $offset = $criteria->getFirstResult();
        if ($limit !== null || $offset !== null) {
            return $this->platform->modifyLimitQuery('', $limit, $offset ?? 0);
        }

        return '';
    }
424069
public static function needsSelectAliases(Criteria $criteria)
    {
        $columnNames = array();
        foreach ($criteria->getSelectColumns() as $fullyQualifiedColumnName) {
            if ($pos = strrpos($fullyQualifiedColumnName, '.')) {
                $columnName = substr($fullyQualifiedColumnName, $pos);
                if (isset($columnNames[$columnName])) {
                    // more than one column with the same name, so aliasing is required
                    return true;
                }
                $columnNames[$columnName] = true;
            }
        }

        return false;
    }
1105098
public function clearTable(string $tableName): bool
    {
        $delete = new DeleteQuery($this->db);

        return $delete->from($tableName)->execute();
    }
894004
public function getByCriteria($criteria, $fieldName)
    {
        /** @var Statement $statement */
        $queryBuilder = $this->getSelectQueryBuilder();
        $queryBuilder->where($fieldName . " = :criteria");
        $queryBuilder->setParameter('criteria', $criteria);

        $statement = $queryBuilder->execute();
        $rows      = $statement->fetchAll();
        $this->prepareResults($rows);
        return $rows;
    }
816012
public function deleteTable($tableName)
    {
        $deleteStatementStr = "DROP TABLE IF EXISTS {$this->db->platform->quoteIdentifier($tableName)}";
        $deleteStatement = $this->db->query($deleteStatementStr);

        return $deleteStatement->execute();
    }
1083928
public function matching(Criteria $criteria)
    {
        $clause = [];
        /** @var Comparison $whereClause */
        $whereClause = $criteria->getWhereExpression();
        if (null !== $whereClause) {
            if (Comparison::EQ !== $whereClause->getOperator()) {
                throw new \InvalidArgumentException(sprintf('Support for Selectable is limited to the EQUALS "=" operator, 
                 % given', $whereClause->getOperator()));
            }

            $clause = [$whereClause->getField() => $whereClause->getValue()->getValue()];
        }

        return $this->findBy($clause, $criteria->getOrderings(), $criteria->getMaxResults(), $criteria->getFirstResult());
    }
1123358
public function GetCountSQL($criteria)
	{
		$sql = "select count(1) as counter ";
	
		$sql .= $this->GetTableJoinSQL($criteria);
	
		$sql .= $criteria->GetJoin();
	
		$sql .= $this->GetWhereSQL($criteria);
		
		$criteria->Reset();
	
		return $sql;
	}
966353
protected function _delete(array $criteria = array())
    {
        if (!is_null($this->_table)) {
            $this->_affectedRows = $this->_db->delete($this->_table, $criteria);
            return $this->_affectedRows;
        }
    }
1034626
public static function filterEnumByName(
        QueryBuilder $queryBuilder,
        &$criteria,
        $field,
        $enumTypeName,
        $isJoined = false,
        $alias = 'o'
    ) {
        if (isset($criteria[$field])) {
            if (!empty($criteria[$field])) {
                if (!$isJoined) {
                    $queryBuilder->join(sprintf('%s.%s', $alias, $field), 'enum')->join('enum.type', 'enumType');
                }
                $queryBuilder
                    ->andWhere('enumType.name = :enumType')
                    ->andWhere(sprintf('enum.name LIKE :%s', $field))
                    ->setParameter($field, '%'.$criteria[$field].'%')
                    ->setParameter('enumType', $enumTypeName);
            }
            unset($criteria[$field]);
        }

        return $criteria;
    }
604595
public function delete($collection, array $criteria, $multi = TRUE)
	{

		try {
			$writer = new MongoDB\Driver\BulkWrite();
			$writer->delete($criteria, ['limit' => $multi ? 0 : 1]);
			$result = $this->driver->execute($collection, $writer);
		} catch (RuntimeException $e) {
			$this->createException($e);
		}

		if ($count = $result->getDeletedCount()) {
			return $count;
		}

		return FALSE;
	}
873477
public function cuDelete($tableName, $where)
    {

        $result = null;
        $where  = trim($where);
        if ($where !== '') {

            $query = 'DELETE FROM `%s` WHERE %s';
            $query = sprintf($query, $tableName, $where);

            $result = $this->cuQuery($query);
        }

        return $result;
    }
435836
public function countByCriteria(Criteria $criteria)
    {
        $qb = $this->createCriteriaQueryBuilder($criteria, 'm');

        $qb->select('COUNT(m.id)');

        return $qb->getQuery()->getSingleScalarResult();
    }
631415
public int deleteByTableName(String tableName) throws SQLException {
		DeleteBuilder<DataColumns, TableColumnKey> db = deleteBuilder();
		db.where().eq(DataColumns.COLUMN_TABLE_NAME, tableName);
		PreparedDelete<DataColumns> deleteQuery = db.prepare();
		int deleted = delete(deleteQuery);
		return deleted;
	}