Executes a statement using a read connection from the pool.

@param string  $statement
@param mixed[] $parameters

@throws ConnectionException

@return Result
434378
private function executeRead($statement, array $parameters)
    {
        if ($this->transactionCount == 0) {
            $connection = $this->pool->selectReadConnection();
        } else {
            $connection = $this->transactionConnection;
        }

        try {
            return $connection->execute(
                $this->expandPlaceholders($statement, $parameters),
                $parameters
            );
        } catch (ConnectionException $e) {
            $this->pool->disableReadConnection($connection);
            if ($this->pool->getReadConnectionCount() == 0) {
                throw $e;
            }

            return $this->executeRead($statement, $parameters);
        }
    }
335114
protected function _executeStatement($statement, $sql, $params) {
        if ((!$statement->execute($params))) {
            throw new DbException($this->_pdoObject->errorInfo(), $sql, $params, $this->_errorReporting);
        }

        if ($statement->errorCode() == '00000') {
            return;
        }
        throw new DbException($statement->errorInfo(), $sql, $params, $this->_errorReporting);
    }
391957
private function executeQuery(string $query, array $parameters) : bool
    {
        $statement = $this->pdo->prepare($query);
        $statement->execute($parameters);

        return $statement->rowCount() !== 0;
    }
365705
public function execute($sql, array $parameters = array())
    {
        $this->logger->info($sql, array('parameters' => $parameters));

        try {
            $statement = $this->getPdo()->prepare($sql);
            $statement->execute($parameters);
        } catch (PDOException $exception) {
            $this->logger->error($exception->getMessage());

            throw $exception;
        }

        return $statement;
    }
244719
public void execute(String statement) throws SQLException {
		if (logger.isDebugEnabled()) {
			logger.debug("Executing SQL statement [" + statement + "]");
		}
		
		Connection connection = null;
		Statement stm = null;
		
		try{
			connection = ds.getConnection();
			stm = connection.createStatement();			
			stm.execute(statement);
		} catch (SQLException e) {
			throw e;
		}finally{
			if(stm!=null) stm.close();
			if(connection!=null) connection.close();			
		}
				
	}
659433
public function exec($statement)
    {
        $result = $this->mysqli->query($statement);

        if ($result === false) {
            throw new MysqliException($this->mysqli->error, $this->mysqli->errno);
        }

        return $this->mysqli->affected_rows;
    }
496375
private function expandPlaceholders($statement, array $parameters)
    {
        $index = 0;

        return preg_replace_callback(
            '/[\.]{3}\?|\?/',
            function ($match) use (&$index, &$statement, &$parameters) {
                if ($match[0] != '...?') {
                    ++$index;

                    return $match[0];
                }

                if (!is_array($parameters[$index]) || count($parameters[$index]) == 0) {
                    throw new OperationException(
                        sprintf(
                            'Variable length parameter %d is not an array.',
                            $index
                        ),
                        $statement
                    );
                }

                $result = implode(',', array_fill(0, count($parameters[$index]), '?'));

                ++$index;

                return $result;
            },
            $statement
        );
    }
997424
public function getSingleResult($statement, $params = array())
    {
        $result = $this->getResults($statement, $params);

        if (!sizeof($result)) {
            return null;
        }

        return $result[0];
    }
376431
public function execute(string $query, array $parameters = []): int
    {
        return $this->statement($query, $parameters)->rowCount();
    }
1036747
protected function bindParameters(Statement $statement, array $parameters): Statement
    {
        foreach ($parameters as $index => $parameter) {
            if (is_numeric($index)) {
                //Numeric, @see http://php.net/manual/en/pdostatement.bindparam.php
                $statement->bindValue($index + 1, $parameter->getValue(), $parameter->getType());
            } else {
                //Named
                $statement->bindValue($index, $parameter->getValue(), $parameter->getType());
            }
        }

        return $statement;
    }
930349
public function executeStatement($statementQuery, array $parameters) {
		$statement = $this->connection->prepare($statementQuery);
		foreach ($parameters as $parameterName => $parameterValue) {
			$statement->bindValue($parameterName, $parameterValue);
		}

		$result = $statement->execute();
		$resultArray = array();
		while ($resultRow = $result->fetchArray(SQLITE3_ASSOC)) {
			$resultArray[] = $resultRow;
		}

		return $resultArray;
	}
1160697
public function execute($query, $parameters = [])
    {
        $startTimestamp = time();

        $exception = null;

        try {
            $result = $this->internalAdapter->execute($query, $parameters);
        } catch (\Exception $e) {
            $exception = $e;
        } finally {
            //log
            $this->log(
                $query,
                $parameters,
                $startTimestamp,
                $exception
            );

            if ($exception) {
                throw $exception;
            }
        }

        return $result;
    }
847963
public function fetch($query, $parameters = array())
    {
        try {
            $sth = $this->query($query, $parameters);
            if ($sth === false) {
                return false;
            }
            return $sth->fetch(PDO::FETCH_ASSOC);
        } catch (PDOException $e) {
            throw new DbException("Error query: " . $e->getMessage());
        }
    }
1342024
private function doStoreStatements($statements, $method = 'post', $parameters = array(), $validStatusCode = 200)
    {
        $attachments = array();

        if (is_array($statements)) {
            foreach ($statements as $statement) {
                if (null !== $statement->getAttachments()) {
                    foreach ($statement->getAttachments() as $attachment) {
                        if ($attachment->getContent()) {
                            $attachments[] = $attachment;
                        }
                    }
                }
            }

            $serializedStatements = $this->statementSerializer->serializeStatements($statements);
        } else {
            if (null !== $statements->getAttachments()) {
                foreach ($statements->getAttachments() as $attachment) {
                    if ($attachment->getContent()) {
                        $attachments[] = $attachment;
                    }
                }
            }

            $serializedStatements = $this->statementSerializer->serializeStatement($statements);
        }

        $headers = array();

        if (!empty($attachments)) {
            $builder = new MultipartStatementBody($serializedStatements, $attachments);
            $headers = array(
                'Content-Type' => 'multipart/mixed; boundary='.$builder->getBoundary(),
            );
            $body = $builder->build();
        } else {
            $body = $serializedStatements;
        }

        $request = $this->requestHandler->createRequest(
            $method,
            'statements',
            $parameters,
            $body,
            $headers
        );
        $response = $this->requestHandler->executeRequest($request, array($validStatusCode));
        $statementIds = json_decode((string) $response->getBody());

        if (is_array($statements)) {
            /** @var Statement[] $statements */
            $createdStatements = array();

            foreach ($statements as $index => $statement) {
                $createdStatements[] = $statement->withId(StatementId::fromString($statementIds[$index]));
            }

            return $createdStatements;
        } else {
            /** @var Statement $statements */

            if (200 === $validStatusCode) {
                return $statements->withId(StatementId::fromString($statementIds[0]));
            } else {
                return $statements;
            }
        }
    }
494011
public function query($statement, $param1 = null, $param2 = null, $param3 = null)
    {
        if ($param3 !== null) {
            return parent::query($statement, $param1, $param2, $param3);
        }

        if ($param2 !== null) {
            return parent::query($statement, $param1, $param2);
        }

        if ($param1 !== null) {
            return parent::query($statement, $param1);
        }

        return parent::query($statement);
    }
1260219
public static function Fetch($statement, $parameters=array(), $fetchMode=PDO::FETCH_BOTH)
	{
		$db = self::connect($fetchMode);
		
		try
		{
			$query = $db->prepare($statement);
			
			if($query)
			{
				foreach($parameters as $key => $parameter)
				{
					if(!isset($parameter["type"]))
						$parameter["type"] = PDO::PARAM_STR;
	
					$query->bindParam($key,$parameter["value"],$parameter["type"]);
				}
				
				$query->execute();
			}
			else
			{
				throw new \Exception("Sorry, there was a problem with the query statement.");
			}
		}
		catch (PDOException $e)
		{
			$exception = "Sorry, there was a problem with the query. ({$e->getMessage()})";
		}

		if($exception) throw new \Exception($exception);
		
		return $query->fetch($fetchMode);
	}
626954
protected function push(Statement $statement)
    {
        $maxConnections = $this->pool->getConnectionLimit();

        if ($this->statements->count() > ($maxConnections / 10)) {
            return;
        }

        if ($maxConnections === $this->pool->getConnectionCount() && $this->pool->getIdleConnectionCount() === 0) {
            return;
        }

        $this->statements->push($statement);
    }