returns an array of all results selected or an empty array if nothing
was selected or nothing could be selected.

@param string $query
@param array  $criteria

@throws DatabaseException
@return array
438234
public function getResults(string $query, array $criteria = []): array {
		try {
			$results = $this->dbConn->fetchAll($query, $criteria);
			return is_array($results) ? $results : [];
		} catch (\PDOException $pdoException) {
			throw $this->prepareDatabaseException($pdoException, $query, $criteria);
		}
	}
1098349
public static function findAllEntitiesByCriteria(array $criteria = [], array $exclude = []): array
    {
        $class = static::class;

        /** @var EntityRepository $obj_collection */
        $obj_collection = new $class();

        foreach ($criteria as $k => $v) {
            $obj_collection->addSimpleWhereField($k, $v);
        }

        foreach ($exclude as $k => $v) {
            $obj_collection->addWhereFieldIsNot($k, $v);
        }

        return $obj_collection->getAsArrayOfObjects();
    }
865208
public function grabFromDatabase( $table, $columns, $criteria = array() ) {
		$query = $this->_prepareQuery( $table, $columns, $criteria );
		$this->debugSection( 'Query', $query );

		$suppress_errors = $this->_wpdb->suppress_errors( true );
		$results = $this->_wpdb->get_results( $query );
		$this->_wpdb->suppress_errors( $suppress_errors );

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

		return $results;
	}
396482
public function select($query, $bindings = [], $useReadPdo = true)
    {
        return $this->run($query, $bindings, function ($query, $bindings) use ($useReadPdo) {
            if ($this->pretending()) {
                return [];
            }

            // For select statements, we'll simply execute the query and return an array
            // of the database result set. Each element in the array will be a single
            // row from the database table, and will either be an array or objects.
            $statement = $this->prepared($this->getPdoForSelect($useReadPdo)
                              ->prepare($query));

            $this->bindValues($statement, $this->prepareBindings($bindings));

            $statement->execute();

            return $statement->fetchAll();
        });
    }
537376
protected function parseSubSelect($query) {
        if ($query instanceof self) {
            $query->columns = [$query->columns[0]];

            return [$query->toSql(), $query->getBindings()];
        } elseif (is_string($query)) {
            return [$query, []];
        } else {
            throw new \InvalidArgumentException();
        }
    }
801881
public function toQuery ($query)
		{
			if (is_object($query)) {
				$query = clone $query;
			}

			if ($query instanceof DatabaseQuery) {
				return $query;

			} else if ($query instanceof DatabaseQueryCondition) {
				return $this->createQuery()->where($query);

			} else if (is_null($query)) {
				return $this->createQuery();

			} else {
				throw new DatabaseException('Invalid query/condition type.');
			}
		}
1050238
public function select($query)
    {
        $clause = 'SELECT @DISTINCT';

        if ($query->operation['type'] & AnDomainQuery::QUERY_SELECT_DEFAULT) {
            $description = $query->getRepository()->getDescription();
            $columns = AnDomainQueryHelper::parseColumns($query, $query->columns);
            foreach ($description->getProperty() as $name => $property) {
                if (isset($columns[$name])) {
                    $result = AnDomainQueryHelper::parseColumn($query, $name);
                    if ($result['columns'] instanceof AnDomainResourceColumn) {
                        $columns[] = $columns[$name].' AS '.$this->_store->quoteValue($result['columns']->key());
                        unset($columns[$name]);
                    }
                } elseif ($property->isAttribute()) {
                    $columns[] = $property->getColumn();
                } elseif ($property->isRelationship() && $property->isManyToOne()) {
                    $columns = array_merge($columns, array_values(AnConfig::unbox($property->getColumns())));
                }
            }

            if ($description->getInheritanceColumn()) {
                $columns[] = $description->getInheritanceColumn();
            }

            foreach ($columns as $key => $column) {
                if ($column instanceof AnDomainResourceColumn) {
                    if ($column->resource->getLink()) {
                        $columns[$key] = $column.' AS '.$this->_store->quoteValue((string) $column);
                        continue;
                    } else {
                        $columns[$key] = (string) $column;
                    }
                }
                if (!is_numeric($key)) {
                    $columns[$key] = $column.' AS '.$this->_store->quoteValue($key);
                }
            }
            $clause .= ' '.implode(' , ', $columns);
        } else {
            $columns = (array) $query->operation['value'];
            $columns = AnDomainQueryHelper::parseColumns($query, $columns);
            $clause .= ' '.implode(' , ', $columns);
        }

        return $clause;
    }
913504
public function findAll($criteria = [])
    {
        is_array($criteria) || ($criteria = []);
        $query = 'SELECT * FROM ' . static::TABLE;

        if (isset($criteria['orderby'])) {
            $query .= ' ORDER BY ' . $criteria['orderby'];
        }

        $stmt = AbstractApp::getDbal()->query($query);
        $list = [];

        $primary = $this->getPrimaryKey();

        if ($primary) {
            while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
                $list[$row[$primary]] = $row;
            }
        }
        else {
            while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
                $list[] = $row;
            }
        }

        return $this->extend($list, true);
    }
413071
final public function queryArray(string $query)
    {
        $result = $this->queryResult($query);
        if (false === $result) {
            return false;
        }

        $return = [];
        while (false !== $row = $result->fetchRow()) {
            $return[] = $row;
        }
        return $return;
    }
418930
public function findBy(array $criteria = [], array $orders = [], $limit = null, $offset = null): array
    {
        $queryCriteria = Criteria::create();

        foreach ($criteria as $prop => $value) {
            $queryCriteria->andWhere(Criteria::expr()->eq($prop, $value));
        }

        $queryCriteria->orderBy($orders);

        if ($limit !== null) {
            $queryCriteria->setMaxResults($limit);
        }

        if ($offset !== null) {
            $queryCriteria->setFirstResult($offset);
        }

        return $this->matching($queryCriteria);
    }
10601
public function GetSQL($criteria)
	{
		// start building the sql statement
		$sql = "select " . $this->GetColumnNames() . "";

		$sql .= $this->GetTableJoinSQL($criteria);		

		$sql .= $criteria->GetJoin();
				
		$sql .= $this->GetWhereSQL($criteria);
		
		$sql .= $criteria->GetOrder();
		
		$criteria->Reset();
		
		return $sql;
	}
737697
public function findRecords(string $table, array $criteria = []): array
    {
        $url = $this->getEndpoint($table);

        if (count($criteria) > 0) {
            $formulas = [];
            foreach ($criteria as $field => $value) {
                $formulas[] = sprintf("%s='%s'", $field, $value);
            }

            $url .= sprintf(
                '?filterByFormula=(%s)',
                implode(' AND ', $formulas)
            );
        }

        /** @var Response $response */
        $response = $this->browser->get(
            $url,
            [
                'content-type' => 'application/json',
            ]
        );

        $data = json_decode($response->getContent(), true);

        return array_map(function (array $value) {
            return new Record($value['id'], $value['fields']);
        }, $data['records']);
    }
79261
public function getResults($query)
    {
        $parameters = [];

        if (is_object($query) && $query instanceof SearchQuery) {
            $query = $query->toArray();
        }

        if (is_array($query)) {
            $collection = new Collection($query);

            $query = $collection->pull('query', '');

            $parameters = $collection->toArray();
        }

        return $this->index->search($query, $parameters);
    }
453824
public function getQuery($criteria = [])
    {

        /** @var ElementInterface $elementClass */
        $elementClass = static::elementClass();

        /** @var ElementQueryInterface $query */
        $query = $elementClass::find();

        // Configure it
        QueryHelper::configure(
            $query,
            $criteria
        );

        return $query;
    }
407282
public function select($query, $bindings = array())
    {
        $statement  = $this->getActivePdo()->prepare($query);

        if ($statement->execute($bindings)) {
            return $statement->fetchAll($this->fetchMode);
        }

        throw new DbException("Db execute fail [{$query}]");
    }
797939
public function findBy(
        array $criteria,
        ?array $orderBy = null,
        ?int $limit = null,
        ?int $offset = null
    ) : array {
        $objects = [];

        foreach ($this->objects as $object) {
            $matches = true;

            foreach ($criteria as $key => $value) {
                if ($object[$key] === $value) {
                    continue;
                }

                $matches = false;
            }

            if (! $matches) {
                continue;
            }

            $objects[] = $object;
        }

        return $objects;
    }
521025
protected function getHash($query, $criteria, ?array $orderBy = null, $limit = null, $offset = null)
    {
        [$params] = $criteria instanceof Criteria
            ? $this->persister->expandCriteriaParameters($criteria)
            : $this->persister->expandParameters($criteria);

        return sha1($query . serialize($params) . serialize($orderBy) . $limit . $offset);
    }