Executes an SQL query on the storage engine. Should be used for SELECT
only.

@access public
@author Jerome Bogaerts, <jerome@taotesting.com>
@param  string statement
@param  array params
@return PDOStatement
422689
public function query($statement, $params = array())
    {
        $returnValue = null;
        $this->preparedExec = false;

       
        if (count($params) > 0){
        	$sth = $this->dbConnector->prepare($statement);
        	$sth->execute($params);
        }
        else{
        	$sth = $this->dbConnector->query($statement);
        }
        
		
        if (!empty($sth)){
        	$returnValue = $sth;
        }

        return $returnValue;
    }
724027
public function dumpSQL(\PDOStatement $statement = null) {
        if ($statement) {
            @ob_start(PHP_OUTPUT_HANDLER_CLEANABLE);
            $statement->debugDumpParams();
            $this->dumpSQL = @ob_get_clean();

            return null;
        } else {
            return $this->dumpSQL;
        }
    }
1071192
protected function bindParameters(\PDOStatement $statement, array $parameters, $prefix = '')
    {
        foreach ($parameters as $key => $value) {
            // In case of multiple rows are given for insert statement
            if (is_array($value)) {
                $statement = $this->bindParameters($statement, $value, $prefix . $key);
            } else {
                switch (true) {
                    case is_int($value):
                        $type = \PDO::PARAM_INT;
                        break;
                    case is_bool($value):
                        $type = \PDO::PARAM_BOOL;
                        break;
                    case $value === null:
                        $type = \PDO::PARAM_NULL;
                        break;
                    case $value instanceof \DateTimeInterface:
                        $type  = \PDO::PARAM_STR;
                        $value = $value->format('Y-m-d H:i:s.u');
                        break;
                    default:
                        $type = \PDO::PARAM_STR;
                }

                $statement->bindValue($prefix . $key, $value, $type);
            }
        }

        return $statement;
    }
1032674
public Object[] executeMultiplePreparedStatements(String[] statements, Collection inParams) throws SQLException {
		Object[] result;
		if (statements.length == inParams.size()) {
			result = new Object[inParams.size()];
			Connection conn = null;

			conn = dataSource.getConnection();
			conn.setAutoCommit(false);

			try {
				Iterator inParamsIt = inParams.iterator();
				int count = 0;
				while (inParamsIt.hasNext()) {
					Object[] params = (Object[]) inParamsIt.next();
					result[count] = executePreparedStatement(statements[count], new StatementInput(params), false, conn);
					count++;
				}
				conn.commit();
			} catch (SQLException e) {
				throw e;
			} finally {
				if (conn != null) {
					conn.close();
				}
			}
		} else {
			throw new SQLException("number of arguments doesn't match");
		}
		return result;
	}
145107
public static function execute( $sql, $parameters = null, $connection = null, $fetchMode = \PDO::FETCH_ASSOC )
    {
        self::$_statement = self::createStatement( $sql, $connection, $fetchMode );

        if ( empty( $parameters ) )
        {
            return self::$_statement->execute();
        }

        return self::$_statement->execute( $parameters );
    }
1208000
public static function select(
        $table, $fields = array(),
        $condition = null,
        $statement = null)
    {
        $query = array('SELECT ');
        array_push($query, (empty($fields)?'*':implode(', ', $fields)));
        array_push($query, " FROM $table");
        array_push($query, (isset($condition))?" WHERE $condition":'');
        array_push($query, (isset($statement))?" $statement":'');
        return implode($query);
    }
637577
protected function createQueryStatement(string $sql): PDOStatement
    {
        $statement = $this->pdo->query($sql);

        if (!$statement instanceof PDOStatement) {
            throw new RuntimeException('Invalid statement');
        }

        return $statement;
    }
300634
public function prepare($statement, $driverOpts = null) {
		if ($driverOpts === null) {
			$driverOpts = [];
		}

		try {
			$stmt = $this->pdo->prepare($statement, $driverOpts);
			return new PreparedStatement($stmt, $this->pdo, $this->exceptionAdapter);
		} catch (PDOException $e) {
			throw $this->exceptionAdapter->adapt($e, $statement);
		}
	}
162804
public function _execute(array $params = null)
    {
        try {
            if ($params !== null) {
                return $this->_stmt->execute($params);
            } else {
                return $this->_stmt->execute();
            }
        } catch (PDOException $e) {
            // require_once 'Zend/Db/Statement/Exception.php';
            throw new Zend_Db_Statement_Exception($e->getMessage(), (int) $e->getCode(), $e);
        }
    }
276664
public function execute($sql, $params = array())
    {
        $kvm = KVMLogger::instance('anycontent-database');

        /** @var \PDO $db */
        $dbh = $this->getConnection();

        $stmt = $dbh->prepare($sql);

        $kvm->startStopWatch('anycontent-query-execution-time');

        $stmt->execute($params);

        $duration = $kvm->getDuration('anycontent-query-execution-time');
        $message  = $kvm->createLogMessage($this->debugQuery($sql, $params), [ 'duration' => $duration ]);
        $kvm->debug($message);
        
        $this->queryCounter++;

        return $stmt;
    }
744225
private function prepare($sql, array $params)
    {
        $statement = $this->connection->prepare($sql);
        foreach ($params as $key => $value) {
            $statement->bindValue($key, $value);
        }

        return $statement;
    }
190537
public function action(string $query, array $params = [])
    {
        // Prepares the query, then stores it
        $PDOStatement = $this->pdo->prepare($query);

        // Executes the query, then returns the boolean value
        return $PDOStatement->execute($params);
    }
447584
void executeStatement(String statement) {

		try (Connection conn = getFastConnection(); Statement stm = conn.createStatement()) {
			stm.execute(statement);
		} catch (Exception e) {
			throw new RuntimeException(e);
		}

	}
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);
        }
    }
186130
public function query($statement) {
		try {
			$stmt = $this->pdo->query($statement);
			return new QueryResult($stmt, $this->pdo);
		} catch (PDOException $e) {
			throw $this->exceptionAdapter->adapt($e, $statement);
		}
	}
171671
public function prepare($statement, $options = null)
    {
        $options = is_null($options) ? [] : $options;
        if (strpos($statement, ':') !== false) {
            $i = 0;
            $bindKeyMap = [];
            $statement = preg_replace_callback('/:([a-zA-Z_]\w*?)\b/', function ($matches) use (&$i, &$bindKeyMap) {
                $bindKeyMap[$matches[1]] = $i++;

                return '?';
            }, $statement);
        }

        $stmtObj = $this->client->prepare($statement);

        if ($stmtObj) {
            $stmtObj->bindKeyMap = $bindKeyMap ?? [];

            return new PDOStatement($this, $stmtObj, $options);
        } else {
            $statementException = new StatementException($this->client->error, $this->client->errno);
            throw new QueryException($statement, [], $statementException);
        }
    }
239648
public function statement($sql, $bindings = array())
		{
			list($statement, $result) = $this->execute($sql, $bindings);
			return $result;
		}