public function execute(string $sql, array $resultTypes = [])
    {
        $result = @pg_query($this->getResource(), $sql);

        if (false === $result) {
            throw new exceptions\InvalidQueryException(pg_last_error($this->getResource()));
        }

        switch (pg_result_status($result)) {
            case PGSQL_COMMAND_OK:
                $rows = pg_affected_rows($result);
                pg_free_result($result);
                return $rows;

            case PGSQL_COPY_IN:
            case PGSQL_COPY_OUT:
                pg_free_result($result);
                return true;

            case PGSQL_TUPLES_OK:
            default:
                return new ResultSet($result, $this->getTypeConverterFactory(), $resultTypes);
        }
    }
public function execute(string $sql, array $resultTypes = [])
    {
        $result = @pg_query($this->getResource(), $sql);

        if (false === $result) {
            throw new exceptions\InvalidQueryException(pg_last_error($this->getResource()));
        }

        switch (pg_result_status($result)) {
            case PGSQL_COMMAND_OK:
                $rows = pg_affected_rows($result);
                pg_free_result($result);
                return $rows;

            case PGSQL_COPY_IN:
            case PGSQL_COPY_OUT:
                pg_free_result($result);
                return true;

            case PGSQL_TUPLES_OK:
            default:
                return new ResultSet($result, $this->getTypeConverterFactory(), $resultTypes);
        }
    }
public function execute ( string $ sql , array $ resultTypes = [ ] ) { $ result = @ pg_query ( $ this -> getResource ( ) , $ sql ) ; if ( false === $ result ) { throw new exceptions \ InvalidQueryException ( pg_last_error ( $ this -> getResource ( ) ) ) ; } switch ( pg_result_status ( $ result ) ) { case PGSQL_COMMAND_OK : $ rows = pg_affected_rows ( $ result ) ; pg_free_result ( $ result ) ; return $ rows ; case PGSQL_COPY_IN : case PGSQL_COPY_OUT : pg_free_result ( $ result ) ; return true ; case PGSQL_TUPLES_OK : default : return new ResultSet ( $ result , $ this -> getTypeConverterFactory ( ) , $ resultTypes ) ; } }
Executes a given query

For queries that return rows this method returns a ResultSet object, for
data modification queries it returns the number of affected rows

@param string $sql         SQL query to execute
@param array  $resultTypes Type converters to pass to ResultSet

@return ResultSet|int|bool Execution result.
@throws exceptions\InvalidQueryException
Executes a given query