Executes query
After execution query is reset

@return mixed
432058
public function execute()
    {
        $this->dispatcher->fire(self::EVENT_BEFORE, $this->instance);

        $this->builder->execute();

        $this->dispatcher->fire(self::EVENT_AFTER, $this->instance);

        foreach ($this->relations as $relation) {
            $relation->write($this->instance);
        }

        return $this->instance;
    }
550698
protected function _execute()
    {
        $this->triggerBeforeFind();
        if ($this->_results) {
            $decorator = $this->_decoratorClass();

            return new $decorator($this->_results);
        }

        $statement = $this->getEagerLoader()->loadExternal($this, $this->execute());

        return new ResultSet($this, $statement);
    }
299227
public function execute()
    {
        $result = null;
        // Only return the result of the primary query
        foreach ($this as $query) {
            /** @var QueryBuilder $query */
            try {
                if ($result === null) {
                    $result = $query->execute();
                    if ($query->getType() === 3) {
                        $this->setLastInsertId($query);
                    }
                    foreach ($this->resultCallbacks as $callback) {
                        $callback($query, $result, $this->getParentId());
                    }
                } else {
                    foreach ($this->resultCallbacks as $callback) {
                        $callback($query, $result, $this->getParentId());
                    }
                    $query->execute();
                }
            } catch (\Exception $e) {
                throw $e;
            }
        }

        return $result;
    }
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();
	}
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);
    }
1211959
public function reset()
    {
        $this->builder->resetQueryParts();
        $this->relations = [];
        $this->resetBinds();

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

        return $this;
    }
33112
public function execute()
	{
		$this->connect();

		// Take a local copy so that we don't modify the original query and cause issues later
		$sql = $this->replacePrefix((string) $this->sql);

		// Increment the query counter.
		$this->count++;

		// If debugging is enabled then let's log the query.
		if ($this->debug)
		{
			// Add the query to the object queue.
			$this->log(
				Log\LogLevel::DEBUG,
				'{sql}',
				array('sql' => $sql, 'category' => 'databasequery', 'trace' => debug_backtrace())
			);
		}

		// Reset the error values.
		$this->errorNum = 0;
		$this->errorMsg = '';

		// Execute the query.
		$this->executed = false;

		if ($this->prepared instanceof \mysqli_stmt)
		{
			// Bind the variables:
			if ($this->sql instanceof PreparableInterface)
			{
				$bounded =& $this->sql->getBounded();

				if (\count($bounded))
				{
					$params     = array();
					$typeString = '';

					foreach ($bounded as $key => $obj)
					{
						// Add the type to the type string
						$typeString .= $obj->dataType;

						// And add the value as an additional param
						$params[] = $obj->value;
					}

					// Make everything references for call_user_func_array()
					$bindParams   = array();
					$bindParams[] = &$typeString;

					for ($i = 0, $iMax = \count($params); $i < $iMax; $i++)
					{
						$bindParams[] = &$params[$i];
					}

					\call_user_func_array(array($this->prepared, 'bind_param'), $bindParams);
				}
			}

			$this->executed = $this->prepared->execute();
			$this->cursor   = $this->prepared->get_result();

			// If the query was successful and we did not get a cursor, then set this to true (mimics mysql_query() return)
			if ($this->executed && !$this->cursor)
			{
				$this->cursor = true;
			}
		}

		// If an error occurred handle it.
		if (!$this->executed)
		{
			$this->errorNum = (int) $this->connection->errno;
			$this->errorMsg = (string) $this->connection->error;

			// Check if the server was disconnected.
			if (!$this->connected())
			{
				try
				{
					// Attempt to reconnect.
					$this->connection = null;
					$this->connect();
				}
				catch (ConnectionFailureException $e)
				{
					// If connect fails, ignore that exception and throw the normal exception.
					$this->log(
						Log\LogLevel::ERROR,
						'Database query failed (error #{code}): {message}; Failed query: {sql}',
						array('code' => $this->errorNum, 'message' => $this->errorMsg, 'sql' => $sql)
					);

					throw new ExecutionFailureException($sql, $this->errorMsg, $this->errorNum);
				}

				// Since we were able to reconnect, run the query again.
				return $this->execute();
			}

			// The server was not disconnected.
			$this->log(
				Log\LogLevel::ERROR,
				'Database query failed (error #{code}): {message}; Failed query: {sql}',
				array('code' => $this->errorNum, 'message' => $this->errorMsg, 'sql' => $sql)
			);

			throw new ExecutionFailureException($sql, $this->errorMsg, $this->errorNum);
		}

		return $this->cursor;
	}
918827
public function execute()
	{
		$this->connect();

		if (!is_resource($this->connection))
		{
			$this->log(
				Log\LogLevel::ERROR,
				'Database query failed (error #{code}): {message}',
				array('code' => $this->errorNum, 'message' => $this->errorMsg)
			);
			throw new \RuntimeException($this->errorMsg, $this->errorNum);
		}

		// Take a local copy so that we don't modify the original query and cause issues later
		$sql = $this->replacePrefix((string) $this->sql);

		if ($this->limit > 0 || $this->offset > 0)
		{
			$sql .= ' LIMIT ' . $this->limit . ' OFFSET ' . $this->offset;
		}

		// Increment the query counter.
		$this->count++;

		// If debugging is enabled then let's log the query.
		if ($this->debug)
		{
			// Add the query to the object queue.
			$this->log(
				Log\LogLevel::DEBUG,
				'{sql}',
				array('sql' => $sql, 'category' => 'databasequery', 'trace' => debug_backtrace())
			);
		}

		// Reset the error values.
		$this->errorNum = 0;
		$this->errorMsg = '';

		// Execute the query. Error suppression is used here to prevent warnings/notices that the connection has been lost.
		$this->cursor = @pg_query($this->connection, $sql);

		// If an error occurred handle it.
		if (!$this->cursor)
		{
			// Check if the server was disconnected.
			if (!$this->connected())
			{
				try
				{
					// Attempt to reconnect.
					$this->connection = null;
					$this->connect();
				}
				catch (\RuntimeException $e)
				// If connect fails, ignore that exception and throw the normal exception.
				{
					// Get the error number and message.
					$this->errorNum = (int) pg_result_error_field($this->cursor, PGSQL_DIAG_SQLSTATE) . ' ';
					$this->errorMsg = pg_last_error($this->connection) . "\nSQL=$sql";

					// Throw the normal query exception.
					$this->log(
						Log\LogLevel::ERROR,
						'Database query failed (error #{code}): {message}',
						array('code' => $this->errorNum, 'message' => $this->errorMsg)
					);
					throw new \RuntimeException($this->errorMsg);
				}

				// Since we were able to reconnect, run the query again.
				return $this->execute();
			}
			else
			// The server was not disconnected.
			{
				// Get the error number and message.
				$this->errorNum = (int) pg_result_error_field($this->cursor, PGSQL_DIAG_SQLSTATE) . ' ';
				$this->errorMsg = pg_last_error($this->connection) . "\nSQL=$sql";

				// Throw the normal query exception.
				$this->log(
					Log\LogLevel::ERROR,
					'Database query failed (error #{code}): {message}',
					array('code' => $this->errorNum, 'message' => $this->errorMsg)
				);
				throw new \RuntimeException($this->errorMsg);
			}
		}

		return $this->cursor;
	}
108605
public function execute()
    {
        $db = $this->db;

        $qp = array();

        if (isset($this->q['query'])) {
            $sth = $db->prepare($this->q['query']);
        } else {
            $qp = $this->makeQuery();
            $sth = $db->prepare($qp['query']);
            foreach ($qp['params'] as $key => $val) {
                if (is_int($val)) {
                    $sth->bindValue("$key", $val, $db::PARAM_INT);
                } else {
                    $sth->bindValue("$key", $val);
                }
            }
        }

        $sth->execute();

        return $sth;
    }
549293
final protected function execute($query, $ignore_cache = false){
        if( $this->cache_exist($query) && !$ignore_cache ){
            return $this->get_cache($query);
        }else{
            $result = $this->db->query($query);
            $this->clear();
            $this->cache_query($query, $result);
            return $result;
        }
    }
180424
public function lastRow()
    {
        $query = clone $this;
        $offset = $this->limit ? $this->limit['start'] : 0;

        // Limit index to start in case of empty results
        $index = max($this->count() + $offset - 1, 0);
        $query->setLimit(1, $index);
        return $query;
    }
986565
public function execute()
	{
		$pdoStatement = $this->pdo->prepare((string) $this);

		foreach ($this->bindings as $clause => $predicate) {
			foreach ($predicate as $key => $value) {
				$pdoStatement->bindValue(sprintf(':%s%d', $clause, $key + 1), $value, $this->getPdoDataType($value));
			}
		}

		$pdoStatement->execute();

		return new QueryResult($pdoStatement);
	}
707666
public function reset()
    {
        $this->arguments = [];
        $this->section = '';
        $this->format = null;
        $this->createAbsoluteUri = false;
        $this->addQueryString = false;
        $this->argumentsToBeExcludedFromQueryString = [];

        return $this;
    }
98020
public function query() {
    $adapter = $this->getAdapter();
    $sql = $this->getSql();
    // always update offset, since it's most likely not contained in the cache id
    $sql = preg_replace('/OFFSET\s+[0-9]+/i', 'OFFSET '.$this->getRawState(Select::OFFSET), $sql);
    $stmt = $adapter->getDriver()->getConnection()->prepare($sql);
    if (self::$logger->isDebugEnabled()) {
      self::$logger->debug("Execute statement: ".$sql);
      self::$logger->debug($this->getParameters(true));
    }
    return $stmt->execute($this->getParameters(true))->getResource();
  }
949900
public function execute()
	{
		// Check connection
		$this->hasConnectionOrFail();

		// Capture the start time
		$start = microtime(true);

		// Execute the query
		try
		{
			$this->statement->execute();
		}
		catch (\PDOException $e)
		{
			// @FIXME: this should honor error reporting settings
			throw new QueryFailedException($e->getMessage(), 500, $e);
		}

		if ($this->debug)
		{
			// Log it
			$this->log(microtime(true) - $start);
		}

		return $this;
	}
12277
public function execute()
    {
        if (!$this->preExecute($this)) {
            return;
        }

        // Our custom pager starts with 1 but Drupal starts with 0, we need
        // to apply a delta over the page offset to restore this correctly.
        // But we also another problem, we need to know if the page was set
        // in the query, else the default 1 - 0 + 1 will become a positive
        // offset instead of going to page 0.
        // Note that this makes those datasources not compatible with a custom
        // user-forged request as input...
        $limit  = $this->datasourceQuery->getLimit();
        $offset = $this->datasourceQuery->getOffset();

        $this->totalCount = (int)$this->getCountQuery()->execute()->fetchField();
        $this->range($offset, $limit);

        // Count query has run, now run the query normally.
        return $this->query->execute();
    }
335992
public function getQuery() {
		$output	= $this->get('output');
		
		try  {
			$this->set('output', SQLAdapter::SQLQUERY);
			$result = $this->run();
		} catch( \Exception $e ) {
			
		}
		
		$this->set('output', $output);
		
		if( isset($e) ) {
			throw $e;
		}
		
		return $result;
	}