Executes query
After execution query is reset

@return mixed
@throws QueryException
188970
public function execute()
    {
        $this->dispatcher->fire(ReadQuery::EVENT_BEFORE);

        $stmt = $this->executeQuery();
        $result = $this->model->entity() ? $this->fetchAsObject($stmt) : $this->fetchAsAssoc($stmt);

        if (!count($result)) {
            throw new QueryException(sprintf('Result out of range or does not exists for "%s"', $this->model->entity()));
        }

        $this->dispatcher->fire(ReadQuery::EVENT_AFTER);

        $result = array_slice($result, 0, 1, false);

        foreach ($this->relations as $relation) {
            $result = $relation->read($result);
        }

        return $result[0];
    }
941129
public function execute() {
        if(is_null($this->client)) {
            $this->client = $this->getConnection();
        }
        if(is_null($this->query)) {
            throw new Exception('No query');
        }

        list($query_data, $meta) = $this->constructQuery($this->source, $this->query, $this->aggs, $this->post_query, $this->settings);

        $results_set = $this->query($query_data, $meta);
        $results = $this->processResults($results_set, $meta);
        $results = $this->postProcessResults($this->post_query, $results, $meta);

        return $results;
    }
600717
public function run(Query $query)
    {
        return $this->getDisconnectRetry()->run(function () use ($query) {
            $statement = $this->prepare($query);
            $query->getValueBinder()->attachTo($statement);
            $statement->execute();

            return $statement;
        });
    }
1051564
public function execute() {
        if (!$this->checkExists()) {
            if ($this->current === self::OP_SELECT) {
                return new ArrayCollection();
            }

            return false;
        }
        $this->createQuery();

        $model = ($this->expected) ? $this->getRowModel() : null;
        if ($this->current === self::OP_SELECT && $this->isCached()) {
            $result = $this->getCached();
        }
        if (!$result) {
            if ($this->preserveQueries && $this->current !== self::OP_SELECT) // keep all queries except selects
                    $this->doPreserveQueries();
            $result = $this->connection->doPrepare($this->query, $this->values,
                    array(
                'multipleRows' => $this->multiple,
                'model' => $model
            ));

            if ($this->current === self::OP_SELECT) $this->saveCache($result);
            else $this->removeCache();
        }

        if ($this->current === self::OP_SELECT)
                $result = $this->returnSelect($result);
        $this->lastQuery = $this->query . '<pre><code>' . print_r($this->values,
                        true) . '</code></pre>';
        $this->resetQuery();
        return $result;
    }
1285497
public function execute()
    {
        $request = $this->request->getCurrentRequest();

        $iTotalRecords = $this->queryBuilder->getTotalRecords();
        $iTotalDisplayRecords = $this->queryBuilder->getTotalDisplayRecords();

        list($data, $objects) = $this->queryBuilder->getData($this->multiple);

        $id_index = array_search('_identifier_', array_keys($this->getFields()));
        $ids = array();

        array_walk($data, function($val, $key) use ($id_index, &$ids) {
            $ids[$key] = $val[$id_index];
        });

        if (!is_null($this->fixedData)) {
            $this->fixedData = array_reverse($this->fixedData);
            foreach ($this->fixedData as $item) {
                array_unshift($data, $item);
            }
        }

        if (!is_null($this->renderer)) {
            array_walk($data, $this->renderer);
        }

        if (!is_null($this->rendererObj)) {
            $this->rendererObj->applyTo($data, $objects);
        }

        if (!empty($this->multiple)) {
            array_walk($data,
                    function($val, $key) use(&$data, $ids) {
                array_unshift($val, sprintf('<input type="checkbox" name="dataTables[actions][]" value="%s" />', $ids[$key]));
                $data[$key] = $val;
            });
        }

        $output = array(
            "draw" => $request->query->getInt('draw'),
            "recordsTotal" => $iTotalRecords,
            "recordsFiltered" => $iTotalDisplayRecords,
            "data" => $data
        );

        return new JsonResponse($output);
    }
624140
public function reset()
    {

        $this->oosql_limit = null;

        $this->oosql_order = null;

        $this->oosql_where = null;

        $this->oosql_join = null;

        $this->oosql_stmt = null;

        $this->oosql_conValues = array();

        $this->oosql_numargs = null;

        $this->oosql_fromFlag = false;

        $this->oosql_multiFlag = false;

        $this->oosql_del_multiFlag = false;

        $this->oosql_multi = array();

        $this->oosql_del_numargs = null;

        $this->oosql_sql = null;

        $this->oosql_select = null;

        $this->oosql_distinct = false;

        $this->oosql_insert = false;

        $this->oosql_sub = false;

        $this->oosql_table_alias = null;

        $this->oosql_fields = array();

        $this->oosql_entity_obj = null;

        $this->oosql_in = null;

        $this->oosql_between = null;

        $this->oosql_fetchChanged = null;

        $this->oosql_group = null;

        $this->oosql_prepParams = null;

        return $this;
    }
535517
public function doQuery($query_string)
    {
        $this->query = str_replace('{..pref..}', $this->pref, $query_string); // replace {..pref..}
        $this->result = $this->sql->query($this->query); // execute query

        if ($this->result !== false) {
            unset($this->error);
            return $this->result;
        } else {
            $this->error[0] = $this->sql->errorCode(); // error number
            $this->error[1] = $this->sql->errorInfo(); // error text
            $this->error[2] = $this->query;            // query causing the error
            Throw new \ErrorException('SQL Error: [' . $this->error[0] . '] ' . $this->error[1] . "\n" . $this->error[2]);
        }
    }
1346810
public function reset()
    {
        $this->statement = null;
        $this->params = array();
        $this->positionParams = array();
        $this->query = array();
        $this->sql = null;

        return $this;
    }
85985
function query() {
        if(empty($this->sql)) {
            $this->_constructSql();
        }
        list($sql, $param) = $this->_constructSql();
        $this->_reset();
        return $this->execute($sql, $param);
    }
586495
public function execute()
	{
		$query  = $this->factory->builder($this->insert)->process();
		$result = $this->pdo->query($query);
		if(!$result)
		{
			throw new \Exception('An error is while the insertion occurred! (query: "' . $query . '")');
		}

		return $this->pdo->lastInsertId();
	}
770818
public function execute($query, ...$data)
    {
        if ($data) {
            $query = $this->merge($query, $data);
        }

        try {
            return $this->pdo->exec($query);
        } catch (PDOException $exception) {
            throw new QueryException($exception, $query);
        }
    }
1234932
public function getQuery(): Query
    {
        $bindings = new Bindings();

        if (count($this->data) == 0 && $this->select === null) {
            throw new Exception('Can not execute Insert query, no records to insert');
        }

        if ($this->table === null) {
            throw new Exception('Can not execute Insert query when table name is not set');
        }

        $hasFields = count($this->fields) > 0;

        $query = "INSERT INTO {$this->table}";

        if ($hasFields) {
            $query .= ' (';

            foreach ($this->fields as $field) {
                $query .= $field . ',';
            }

            $query = substr($query, 0, -1) . ')';
        }

        if ($this->select !== null) {
            if ($this->select instanceof Select || $this->select instanceof Query) {
                $query .= "\n(\n\t" . str_replace("\n", "\n\t", $this->select->__toString()) . "\n)";
                $bindings->addBindingsFromInstance($this->select->getBindings());
            } else {
                throw new Exception('Can not use non-Select or non-Query instance in INSERT INTO SELECT statement - use Query instance to pass Select query');
            }
        } else {
            $query .= "\nVALUES\n";
            foreach ($this->data as $i1 => $row) {
                $query .= "\t(";

                if ($hasFields) {

                    foreach ($this->fields as $field) {
                        if (isset($row[$field])) {
                            $val = $row[$field];

                            if ($val instanceof Expr) {
                                $query .= "{$val},";
                            } else {
                                //$key = 'i' . $i1 . Query::getKeyIndex();
	                            $key = $bindings->makeAndSet("i{$i1}", $val);
                                $query .= ":{$key},";
                            }
                        } else {
                            $query .= 'NULL,';
                        }
                    }

                    $query = substr($query, 0, -1);

                } else {
                    $values = array_values($row);

                    foreach ($values as $i2 => $val) {
                        if ($val instanceof Expr) {
                            $query .= "{$val},";
                        } else {
                            //$key = 'i' . $i2 . Query::getKeyIndex();
	                        $key = $bindings->makeAndSet("i{$i2}", $val);
                            $query .= ":{$key},";
                        }
                    }

                    $query = substr($query, 0, -1);
                }

                $query .= "),\n";
            }

            $query = substr($query, 0, -2);
        }

        return new Query($query, $bindings, $this->getAdapterConnection());
    }
773187
public function getQuery()
    {
        $idField = $this->documentKey;

        if ($idField == null) {
            throw new QueryException('id should not be null');
        }

        $this->setQuery(sprintf('id:%s', $idField));

        return parent::getQuery();
    }
332001
public function commit()
    {
        try {
            $this->connection->commit();
        } catch (DBALException $e) {
            throw new QueryException($e->getMessage(), $e->getCode(), $e);
        }
    }
659645
public function query($query, ...$data)
    {
        if ($data) {
            $query = $this->merge($query, $data);
        }

        try {
            $statement = $this->pdo->query($query);

            return new Result($statement);
        } catch (PDOException $exception) {
            throw new QueryException($exception, $query);
        }
    }
1211959
public function reset()
    {
        $this->builder->resetQueryParts();
        $this->relations = [];
        $this->resetBinds();

        $this->setQuery();
        $this->values();
        $this->setPrimaryKeyConditions();

        return $this;
    }
794891
protected function executeFilteredQuery()
    {
        $this->logQueryStart();
        $query = new WP_User_Query($this->filters);
        $this->logQueryCompletion($this->toSql($query));
        return $query->results;
    }