Internal method to execute queries which cannot be run as prepared statements.

@param   string  $sql  SQL statement to execute.

@return  boolean

@since   1.5.0
359054
protected function executeUnpreparedQuery($sql)
	{
		$this->connect();

		$cursor = $this->connection->query($sql);

		// If an error occurred handle it.
		if (!$cursor)
		{
			$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->executeUnpreparedQuery($sql);
			}

			// 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);
		}

		$this->freeResult($cursor);

		return true;
	}
522333
protected function runTableCheckCommand($sql)
    {
        $testResults = $this->query($sql);
        foreach ($testResults as $testRecord) {
            if (strtolower($testRecord['Msg_text']) != 'ok') {
                return false;
            }
        }
        return true;
    }
963217
public function query($sql)
    {
        $result = $this->pdo->query($sql);
        $this->executed[] = $sql;
        return $result;
    }
1294087
private function query($sql) {
		if ($sth = $this->DB->query($sql)) {
			$res = $sth->fetchAll(PDO::FETCH_COLUMN);
		} else {
			$res = false;
		}
		return $res;
	}
502572
final public function execute($sql)
    {
        if (!$this->DB) {
            throw  new Exception('您还没有连接数据库', Exception::CODE_DATABASE_ERROR);
        }
        $this->lastQueryAt = time();
        return $this->DB->execute($sql);
    }
860553
public static function execute($sql, $data = [])
    {
        $statement = self::$pdo->prepare($sql);
        $statement->execute($data);
        return $statement;
    }
603799
public function exec($sql) {
        $dialect = $this->dialect;
        if (is_null($dialect)) {
            return false;
        }
        try {
            // 表前缀处理
            $sql = preg_replace_callback('#\{[a-z][a-z0-9_].*\}#i', function ($r) use ($dialect) {
                return $dialect->getTableName($r[0]);
            }, $sql);

            return false !== $dialect->exec($sql);
        } catch (\Exception $e) {
            $this->error = $e->getMessage();

            return false;
        }
    }
970381
public boolean execute(Sql sql) throws SQLException {
		
		long start =  System.currentTimeMillis();
		
		if (sql.validate() == false) {
			return false;
		}
		
		boolean result = false;
		
		PreparedStatement stmt = null;
		try {
			stmt = this.createStatment(conn, sql);
			stmt.execute();
			
			result = true;
		} catch (SQLException e) {
			throw e;
		} finally {
			try {
				if (stmt != null && stmt.isClosed() == false) {
					stmt.close();
				}
			} catch (SQLException e) {
				logger.error(e.getMessage(), e);
			}
		}
		
		logger.debug(String.format("Execute %s used %d ms", sql.getSql(), System.currentTimeMillis() - start));

		return result;
	}
1131920
public function execute($sql)
	{

		//put this in try...catch block for better error handling
		try{

			//check if there is a valid service instance
			if (! $this->validService() ) 
			{
				//throw exceptions
				throw new MySQLException("Not connected to a valid database service");

			}

			//execute query and return response object
			return $this->service->query($sql);

		}

		//diplay error message
		catch(MySQLException $MySQLExceptionObject){

			//display error message
			$MySQLExceptionObject->errorShow();

		}

	}
62491
public function query($sql)
    {
        $sql = trim($sql);
        if (empty($sql)) {
            $callers = debug_backtrace();
            $msg = "Sorry I don't understand your SQL: " . PHP_EOL . $sql . PHP_EOL . PHP_EOL;
            $msg.= "I have been called by {$callers[1]['class']}::{$callers[1]['function']}";
            throw new \InvalidArgumentException($msg);
        }

        $data = array();
        $this->log->debug($this->logPrefix . 'Query: ' . preg_replace('/\s+/', ' ', $sql));

        $res = $this->sugarDb->query($sql, false);
        // Error in Query
        if (!empty($this->sugarDb->database->error)) {
            throw new \InvalidArgumentException("SQL Error in query: {$this->sugarDb->database->error}");
        }

        // No data to send to the caller
        if (!isset($res->num_rows)) {
            return true;
        }

        // Empty result
        if ($res->num_rows === 0) {
            return array();
        }

        // data to send
        while ($row = $res->fetch_assoc()) {
            $data[] = $row;
        }
        $res->free();

        return $data;
    }
570395
public function exec($sql)
    {
        if ($this->useDebug) {
            $debug = $this->getDebugSnapshot();
        }

        $return = parent::exec($sql);

        if ($this->useDebug) {
            $this->log($sql, null, __METHOD__, $debug);
            $this->setLastExecutedQuery($sql);
            $this->incrementQueryCount();
        }

        return $return;
    }
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;
    }
239648
public function statement($sql, $bindings = array())
		{
			list($statement, $result) = $this->execute($sql, $bindings);
			return $result;
		}
1121821
public static function dbQuery($sql) {
        
        try {
            return self::query($sql);   
        } catch (PDOException $e) {
            die(self::dbError($sql));
        }
    }
275255
public function execSql($sql)
    {
        try {
            list ($statement) = explode(" ", ltrim($sql));
            if (in_array(strtoupper($statement), array('SELECT', 'SHOW'))) {
                $oStatement = $this->query($sql);
            } else {
                return $this->exec($sql);
            }

            return $oStatement;
        } catch (PDOException $e) {
            throw new Exception("Could not execute sql: " . $sql);
        }
    }
715641
public function prepare(string $sql = null)
    {
        $this->sqlQuery = $this->getConnection()->prepare($this->getSql($sql));

        return $this;
    }
1359238
public function prepareAndExecuteSql($sql, $binds = [])
    {
        $prepare = $this->prepareSQL($sql, $binds);

        return $this->executePrepared($prepare);
    }