Executes a sql file.

@param string $sFile

@return bool
@throws oxConnectionException
974293
protected static function _executeSqlFile($sFile)
    {
        $blSuccess = false;
        $sFileWithPath = dirname(__FILE__) . '/../../../_db/' . $sFile;

        if (file_exists($sFileWithPath)) {
            $sSqlFile = file_get_contents($sFileWithPath);
            $aSqlRows = explode(';', $sSqlFile);
            $aSqlRows = array_map('trim', $aSqlRows);

            foreach ($aSqlRows as $sSqlRow) {
                if ($sSqlRow !== '') {
                    self::_getDatabase()->execute($sSqlRow);
                }
            }

            $blSuccess = true;
        }

        return $blSuccess;
    }
1228219
public function execute($sql) {
        $sql = $this->translateQuery($sql);
        $this->getConnector()->execute($sql);
        return $this;
    }
99897
private function executeQuery($sQuery)
    {
        $oDB = \OxidEsales\Eshop\Core\DatabaseProvider::getMaster();
        $oDB->execute($sQuery);
    }
1224833
public function execute()
    {
        $this->columns = $this->columns ?: '*';
        $query = "SELECT {$this->columns} FROM $this->table ";

        if ($this->joins) {
            $query .= $this->joins;
        }

        $query .= $this->query;

        if (is_null($this->filename)) {
            $this->filename = '/tmp/file.csv';
        }

        $query .= "
            INTO OUTFILE '{$this->filename}'
            CHARACTER SET utf8
            FIELDS TERMINATED BY ','
            ENCLOSED BY '\"'
            LINES TERMINATED BY '\n'
        ";

        $statement = $this->db->prepare($query);
        $r = $statement->execute();

        if ($this->titles) {
            $file = file_get_contents($this->filename);
            file_put_contents($this->filename, $this->titles . "\n" . $file);
        }

        return $this->filename;
    }
495780
public function execute()
    {
        $path  = $this->phpci->buildPath;
        $build = $this->build;

        if ($this->directory == $path) {
            return false;
        }

        $filename = str_replace('%build.commit%', $build->getCommitId(), $this->filename);
        $filename = str_replace('%build.id%', $build->getId(), $filename);
        $filename = str_replace('%build.branch%', $build->getBranch(), $filename);
        $filename = str_replace('%project.title%', $build->getProject()->getTitle(), $filename);
        $filename = str_replace('%date%', date('Y-m-d'), $filename);
        $filename = str_replace('%time%', date('Hi'), $filename);
        $filename = preg_replace('/([^a-zA-Z0-9_-]+)/', '', $filename);

        $curdir = getcwd();
        chdir($this->phpci->buildPath);

        if (!is_array($this->format)) {
            $this->format = array($this->format);
        }

        foreach ($this->format as $format) {
            switch ($format) {
                case 'tar':
                    $cmd = 'tar cfz "%s/%s.tar.gz" ./*';
                    break;
                default:
                case 'zip':
                    $cmd = 'zip -rq "%s/%s.zip" ./*';
                    break;
            }

            $success = $this->phpci->executeCommand($cmd, $this->directory, $filename);
        }

        chdir($curdir);

        return $success;
    }
957452
public function query(string $sql, array $otpions = [])
    {
        $isAssociativeArray = function ($array) {  // return true si c'est un array associatif
            if (!is_array($array) || empty($array)) {
                return false;   
            }

            $keys = array_keys($array);
            
            return (array_keys($keys) !== $keys);
        };

        $this->prepare($sql);

        if ($otpions) {
            if ($isAssociativeArray($otpions)) {
                foreach ($otpions as $key => $value) {
                    $this->bind($key, $value, $this->bindDataType($value));
                }
            } else {
                $i = 1;
                foreach ($otpions as $value) {
                    $this->bind($i, $value, $this->bindDataType($value));
                    $i++;
                }
            }
        }

        $this->sqlQuery->execute();

        return $this->sqlQuery;
    }
1275874
public function detectFromFile(string $sFile): string
    {
        if (!file_exists($sFile)) {
            return '';
        }

        $rHandle = finfo_open(FILEINFO_MIME_TYPE);
        $sMime   = finfo_file($rHandle, $sFile);

        if ($sMime === 'application/octet-stream' || empty($sMime)) {
            $sMime = $this->oDetector->getType($sFile);
        }

        return $sMime ?? 'application/octet-stream';
    }
953159
private function _openSHXFile($toWrite = false)
    {
        $this->SHXFile = $this->_openFile($toWrite, '.shx', 'Index');
        if (! $this->SHXFile) {
            return false;
        }

        return true;
    }
810332
public function executeScript(Database $db, $file)
    {
        $scripts = $this->configuration->getMigrationsScriptDirectory();
        if (null === $scripts) {
            throw new \RuntimeException('Missing Configuration for migrations script directory');
        }

        $path = realpath($scripts . '/' . $file);
        if (!file_exists($path)) {
            throw new \InvalidArgumentException(sprintf('Could not execute %s. File does not exist.', $path));
        }

        try {
            $js = file_get_contents($path);
            if (false === $js) {
                throw new \Exception('file_get_contents returned false');
            }
        } catch (\Exception $e) {
            throw $e;
        }

        $result = $db->command(['$eval' => $js, 'nolock' => true]);

        if (isset($result['errmsg'])) {
            throw new \Exception($result['errmsg'], isset($result['errno']) ? $result['errno'] : null);
        }

        return $result;
    }
987762
def script(self, sql_script, split_algo='sql_split', prep_statements=True, dump_fails=True):
        """"""
        return Execute(sql_script, split_algo, prep_statements, dump_fails, self)
1337214
final protected function executeSqlFromFile($file)
    {
        if (is_file($file)) {
            return $this->executeSqlFromString(file_get_contents($file));
        } else {
            throw new RuntimeException(sprintf('Can not read file at "%s"', $file));
        }
    }
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();
        }
    }
334579
function insertFile( $path, $sqlFile, $usePathType = true )
    {
        $type = $this->databaseName();

        if ( $usePathType )
            $sqlFileName = eZDir::path( array( $path, $type, $sqlFile ) );
        else
            $sqlFileName = eZDir::path( array( $path, $sqlFile ) );
        if ( !file_exists( $sqlFileName ) )
        {
            eZDebug::writeError( "File not found: $sqlFileName", __METHOD__ );
            return false;
        }
        $sqlFileHandler = fopen( $sqlFileName, 'rb' );
        $buffer = '';
        $done = false;
        while ( count( ( $sqlArray = $this->prepareSqlQuery( $sqlFileHandler, $buffer ) ) ) > 0 )
        {
            // Turn unneccessary SQL debug output off
            $oldOutputSQL = $this->OutputSQL;
            $this->OutputSQL = false;
            if ( $sqlArray && is_array( $sqlArray ) )
            {
                $done = true;
                foreach( $sqlArray as $singleQuery )
                {
                    $singleQuery = preg_replace( "/\n|\r\n|\r/", " ", $singleQuery );
                    if ( preg_match( "#^ */(.+)$#", $singleQuery, $matches ) )
                    {
                        $singleQuery = $matches[1];
                    }
                    if ( trim( $singleQuery ) != "" )
                    {
//                    eZDebug::writeDebug( $singleQuery );
                        $this->query( trim( $singleQuery ) );
                        if ( $this->errorNumber() )
                        {
                            return false;
                        }
                    }
                }

            }
            $this->OutputSQL = $oldOutputSQL;
        }
        return $done;

    }
868850
public static function execute($sql, $bind = []) {
        /* @var $connection Connection */
        $connection = Pool::get(Connection::class);
        try {
            $connection->execute($sql, $bind);
            Pool::release($connection);
        } catch (\RuntimeException $e) {
            Pool::release($connection);
            throw $e;
        } catch (\Error $e) {
            Pool::release($connection);
            throw $e;
        }

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

		if (!is_object($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->offset . ', ' . $this->limit;
		}

		// 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 = @mysqli_query($this->connection, $sql);

		// If an error occurred handle it.
		if (!$this->cursor)
		{
			$this->errorNum = (int) mysqli_errno($this->connection);
			$this->errorMsg = (string) mysqli_error($this->connection) . "\n-- SQL --\n" . $sql;

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

				// Since we were able to reconnect, run the query again.
				return $this->execute();
			}
			else
			// The server was not disconnected.
			{
				$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);
			}
		}

		return $this->cursor;
	}
855372
def execute(self, conn, logical_file_name='', block_id=0, block_name='', transaction=False):
        
        sql = ''
        binds = {}

        if logical_file_name:
            if isinstance(logical_file_name, basestring):
                wheresql = "WHERE F.LOGICAL_FILE_NAME = :logical_file_name"
                binds = {"logical_file_name": logical_file_name}
                sql = "{sql} {wheresql}".format(sql=self.sql, wheresql=wheresql)
            elif isinstance(logical_file_name, list): 
                wheresql = "WHERE F.LOGICAL_FILE_NAME in (SELECT TOKEN FROM TOKEN_GENERATOR)"
                lfn_generator, binds = create_token_generator(logical_file_name)
                sql = "{lfn_generator} {sql} {wheresql}".format(lfn_generator=lfn_generator, sql=self.sql,
                        wheresql=wheresql)
        elif block_id != 0:
            wheresql = "WHERE F.BLOCK_ID = :block_id"
            binds ={'block_id': block_id}
            sql = "{sql} {wheresql}".format(sql=self.sql, wheresql=wheresql)
        elif block_name:
            joins = "JOIN {owner}BLOCKS B on B.BLOCK_ID = F.BLOCK_ID".format(owner=self.owner)
            wheresql = "WHERE B.BLOCK_NAME= :block_name"
            binds ={'block_name': block_name}
            sql = "{sql} {joins} {wheresql}".format(sql=self.sql, joins=joins, wheresql=wheresql)
        else:
            return

        cursors = self.dbi.processData(sql, binds, conn, transaction=transaction, returnCursor=True)
        for i in cursors:
            d = self.formatCursor(i, size=100)
            if isinstance(d, list) or isinstance(d, GeneratorType):
                for elem in d:
                    yield elem
            elif d: 
                yield d
775064
@Override
    public boolean execute() throws SQLException {
        boolean isOk = false;

        try {
            boolean result = internalStmt.execute();
            isOk = true;

            return result;
        } finally {
            poolableConn.updateLastSQLExecutionTime(isOk);
        }
    }