execute SQL query.

@param string

@return mixed
356096
public static function query($sql)
    {
        exception_if(self::$server == 'out', AppSetupException::class);

        return self::$server->query($sql);
    }
737181
protected function _execute($sql)
	{
		return ibase_query(isset($this->_ibase_trans) ? $this->_ibase_trans : $this->conn_id, $sql);
	}
996562
public function query(string $sql, $data = null) {
		$connection = $this->pool->getConnection();
		$result = null;
		$tryAgain = true;
SQL_START_EXECUTE:
		if (is_array($data) && count($data) > 0) {
			if (strpos($sql, ':') !== false) {
				$bind = [];
				$sql = preg_replace_callback('/:(\w+)\b/', function ($matches) use (&$data, &$bind) {
					$bind[] = $data[$matches[1]];
					return '?';
				}, $sql);
				$data = &$bind;
			}
			try {
				$st = $connection->prepare($sql);
				if ($st === false) {
					goto SQL_TRY_AGAIN;
				}
				if (is_object($st)) {
					$result = $st->execute($data);
				} else {
					$result = $connection->execute($data);
				}
			} catch (\Throwable $e) {
				goto SQL_TRY_AGAIN;
			}
			if ($result === false) {
				goto SQL_TRY_AGAIN;
			}
			goto SQL_SUCCESS_RETURN;
		} else {
			try {
				$result = $connection->query($sql);
			} catch (\Throwable $e) {
				goto SQL_TRY_AGAIN;
			}
			if ($result === false) {
				goto SQL_TRY_AGAIN;
			}
			goto SQL_SUCCESS_RETURN;
		}
SQL_TRY_AGAIN:
		if (($connection->errno === 2006 || $connection->errno === 2013) && $tryAgain) {
			$tryAgain = false;
			$connection = $this->pool->reconnect($connection);
			goto SQL_START_EXECUTE;
		} else {
			$error = $connection->error;
			$errno = $connection->errno;
			$this->pool->freeConnection($connection);
			throw new DBException($error, $errno);
		}
SQL_SUCCESS_RETURN:
		if ($result === true) {
			$result = [
				'_affected_rows' => $connection->affected_rows
			];
			if (stripos($sql, 'insert') === 0) {
				$result['_insert_id'] = $connection->insert_id;
			}
		}
		$this->pool->freeConnection($connection);
		return $result;
	}
1151066
public function execute($params = [])
    {
        return $this->getDb()
            ->createCommand()
            ->setText($this->buildSql())
            ->execute(array_merge($this->getParams(), $params));
    }
1273079
public function execute($sql, $params = null)
    {
        $stmt = $this->_pdo->prepare($sql);

        if (is_array($params)) {
            foreach ($params as $token => $value) {
                $stmt->bindValue($token, $value);
            }
        }

        try {
            $stmt->execute();
        } catch (PDOException $exception) {
            $this->_database->error('execute', $exception);
        }

        return $stmt;
    }
876270
public function execute( $parameters = null )
    {
        if ( empty( $parameters ) )
        {
            $_result = $this->_statement->execute();
        }
        else
        {
            $_result = $this->_statement->execute( $parameters );
        }

        if ( false === $_result )
        {
            $this->_errorInfo = $this->_statement->errorInfo();
            Log::error( 'SQL error: [' . $this->_errorInfo[0] . '-' . $this->_errorInfo[1] . '] ' . $this->_errorInfo[2] );
        }

        return $this->_executeResult = $_result;
    }
197784
public function exec($sql)
    {
        $result = $this->pdo->exec($sql);
        $this->executed[] = $sql;
        return $result;
    }
290178
public function executeQuery($query = null)
    {
        $connection = $this->getConnection();
        
        $connection->transaction(function (ConnectionInterface $connection) use ($query) {
            $connection->execute($query);
        });
        
        return $connection->affectedRows();
    }
1253861
public function query($sql)
    {
        $this->useConfiguredDatabase();
        $return = $this->getDbConnection()->query($sql);
        $this->checkForDatabaseError($sql, 'query');
        return $return;
    }
1364737
function sql($sql = null, $params = NULL) {
        $params = $this->autoarr($params);
        $sql = str_replace('table.',$this->alias.'.',$sql);
        return $this->execute($sql, $params);
        return $this;
    }
1307572
protected function query($sql) {
        $vars = func_get_args();
		$cleaner = "/[\s,].+|[^a-zA-Z]/";
		$illegal = "/[\\\\'\"\%]/";
        try {
            $pdo = $this->dbConnect();
            $stmt = $pdo->prepare($sql);
            $binds = explode(':', $sql);
            foreach($binds as $n => $b) {
				if($n != 0 && substr($b,1)!=false) {
					$b = ':' . preg_replace($cleaner,'',$b);
					$vars[$n] = preg_replace($illegal,'',$vars[$n]);
					$stmt->bindParam($b,$vars[$n]);
				}
            }
            $stmt->execute();
            return (strpos($sql,'SELECT') !== FALSE) ? $stmt->fetchAll() : true;
        } catch(PDOException $e) {
            return array('query_error' => $e);
        }
    }
847246
public function execute()
    {
        if (!$this->sessionSet && $this->platform instanceof MySqlPlatform) {
            $this->connection->exec("SET @@SESSION.sql_mode = '';");
            $this->sessionSet = true;
        }

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

        if (!($this->sql instanceof \JDatabaseQuery) && ($this->limit > 0 || $this->offset > 0)) {
            // @TODO
            if ($this->offset > 0) {
                $query .= ' LIMIT ' . $this->offset . ', ' . $this->limit;
            } else {
                $query .= ' LIMIT ' . $this->limit;
            }
        }

        $this->prepared = $this->connection->prepare($query);

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

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

        // If debugging is enabled then let's log the query.
        if ($this->debug) {
            // Add the query to the object queue.
            $this->log[] = $query;

            \JLog::add($query, \JLog::DEBUG, 'databasequery');

            $this->timings[] = microtime(true);
        }

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

        if ($this->prepared instanceof Statement) {
            // Bind the variables:
            if ($this->sql instanceof JDatabaseQueryPreparable) {
                $bounded = $this->sql->getBounded();

                foreach ($bounded as $key => $obj) {
                    $this->prepared->bindParam($key, $obj->value, $obj->dataType, $obj->length, $obj->driverOptions);
                }
            }

            try {
                $this->executed = $this->prepared->execute();
            } catch (\Exception $previous) {
            }
        }

        if ($this->debug) {
            $this->timings[] = microtime(true);

            if (defined('DEBUG_BACKTRACE_IGNORE_ARGS')) {
                $this->callStacks[] = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
            } else {
                $this->callStacks[] = debug_backtrace();
            }
        }

        // If an error occurred handle it.
        if (!$this->executed) {
            // Get the error number and message before we execute any more queries.
            $errorNum = (int) $this->connection->errorCode();
            $errorMsg = (string) 'SQL: ' . implode(", ", $this->connection->errorInfo());

            // Get the error number and message from before we tried to reconnect.
            $this->errorNum = $errorNum;
            $this->errorMsg = $errorMsg;

            // Throw the normal query exception.
            \JLog::add(
                \JText::sprintf('JLIB_DATABASE_QUERY_FAILED', $this->errorNum, $this->errorMsg),
                \JLog::ERROR,
                'databasequery'
            );
            throw new RuntimeException($this->errorMsg, $this->errorNum, $previous);
        }

        return $this->prepared;
    }
6382
public function execute($sql)
    {
        try{
            if(null === $this->queryType)
            {
                $this->queryType = QueryType::WRITE;
            }
            if(!$this->isInitDb)
            {
                $this->db = Db::getInstance($this->poolName, $this->queryType);
            }
            if(!$this->db)
            {
                return new Result(false);
            }
            $stmt = $this->db->prepare($sql);
            if($stmt)
            {
                if($this->defer)
                {
                    $defer = $stmt->deferExecute($this->binds);
                }
                else
                {
                    $stmt->execute($this->binds) ? $stmt : false;
                }
            }
            return new Result($stmt, $this->modelClass, $defer ?? null);
        } finally {
            $this->__init();
        }
    }
699765
public function executeRawQuery($query)
    {
        $resultSet = null;
        if($this->odbAdapter) {
            if(!empty($query)) {
                $resultSet = $this->getDbAdapter()->query($query, DbAdapter::QUERY_MODE_EXECUTE);

            }
        }


        return $resultSet;
    }
37626
public function execute($input_parameters = null)
    {
        $return = $this->statement->execute($input_parameters);
        if ($this->connection->useDebug) {
            $sql = $this->getExecutedQueryString($input_parameters);
            $this->connection->log($sql);
            $this->connection->setLastExecutedQuery($sql);
            $this->connection->incrementQueryCount();
        }

        return $return;
    }
1101520
public function execute($query)
    {
        $context = $this->getCommandContext();

        $context->query = $query;

        if ($this->getCommandChain()->run('before.execute', $context) !== false) {
            $context->result = $this->_adapter->execute(to_str($context->query));
            $this->getCommandChain()->run('after.execute', $context);
        }

        return $context->result;
    }
288558
function query($sql)
    {
        $res = false;

        for ($i = 0; $i < 2; $i++)
        {
            $res = mysql_query($sql, $this->conn);
            if ($res === false)
            {
                if (mysql_errno($this->conn) == 2006 or mysql_errno($this->conn) == 2013 or (mysql_errno($this->conn) == 0 and !$this->ping()))
                {
                    $r = $this->checkConnection();
                    if ($r === true)
                    {
                        continue;
                    }
                }
                \Swoole\Error::info(__CLASS__." SQL Error", $this->errorMessage($sql));
                return false;
            }
            break;
        }

        if (!$res)
        {
            Swoole\Error::info(__CLASS__." SQL Error", $this->errorMessage($sql));
            return false;
        }
        if (is_bool($res))
        {
            return $res;
        }
        return new MySQLRecord($res);
    }