src/Db/Pgsql/PgConnection.php
public function executeStatement(string $queryString, array $parameters = []): Observable
    {
        /**
         * http://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f=src/interfaces/libpq/fe-exec.c;h=828f18e1110119efc3bf99ecf16d98ce306458ea;hb=6bcce25801c3fcb219e0d92198889ec88c74e2ff#l1381
         *
         * Should make this return a Statement object
         *
         * To use prepared statements, looks like we need to:
         * - Parse (if needed?) (P)
         * - Bind (B)
         *   - Parameter Stuff
         * - Describe portal (D)
         * - Execute (E)
         * - Sync (S)
         *
         * Expect back
         * - Parse Complete (1)
         * - Bind Complete (2)
         * - Row Description (T)
         * - Row Data (D) 0..n
         * - Command Complete (C)
         * - Ready for Query (Z)
         */

        return new AnonymousObservable(
            function (ObserverInterface $observer, SchedulerInterface $scheduler = null) use ($queryString, $parameters) {
                if ($this->connStatus === $this::CONNECTION_NEEDED) {
                    $this->start();
                }
                if ($this->connStatus === $this::CONNECTION_BAD) {
                    $observer->onError(new \Exception('Connection failed'));
                    return new EmptyDisposable();
                }

                $name = 'somestatement';

                $close = new Close($name);
                $this->commandQueue[] = $close;

                $prepare = new Parse($name, $queryString);
                $this->commandQueue[] = $prepare;

                $bind = new Bind($parameters, $name);
                $this->commandQueue[] = $bind;

                $describe = new Describe();
                $this->commandQueue[] = $describe;

                $execute = new Execute();
                $this->commandQueue[] = $execute;

                $sync = new Sync($queryString, $observer);
                $this->commandQueue[] = $sync;

                $this->changeQueueCountInc();

                $this->processQueue();

                return new CallbackDisposable(function () use ($sync) {
                    $this->changeQueueCountDec();
                    if ($this->currentCommand === $sync && $sync->isActive()) {
                        $this->cancelRequest();
                    }
                    $sync->cancel();
                });
            }
        );
    }
public function executeStatement(string $queryString, array $parameters = []): Observable
    {
        /**
         * http://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f=src/interfaces/libpq/fe-exec.c;h=828f18e1110119efc3bf99ecf16d98ce306458ea;hb=6bcce25801c3fcb219e0d92198889ec88c74e2ff#l1381
         *
         * Should make this return a Statement object
         *
         * To use prepared statements, looks like we need to:
         * - Parse (if needed?) (P)
         * - Bind (B)
         *   - Parameter Stuff
         * - Describe portal (D)
         * - Execute (E)
         * - Sync (S)
         *
         * Expect back
         * - Parse Complete (1)
         * - Bind Complete (2)
         * - Row Description (T)
         * - Row Data (D) 0..n
         * - Command Complete (C)
         * - Ready for Query (Z)
         */

        return new AnonymousObservable(
            function (ObserverInterface $observer, SchedulerInterface $scheduler = null) use ($queryString, $parameters) {
                if ($this->connStatus === $this::CONNECTION_NEEDED) {
                    $this->start();
                }
                if ($this->connStatus === $this::CONNECTION_BAD) {
                    $observer->onError(new \Exception('Connection failed'));
                    return new EmptyDisposable();
                }

                $name = 'somestatement';

                $close = new Close($name);
                $this->commandQueue[] = $close;

                $prepare = new Parse($name, $queryString);
                $this->commandQueue[] = $prepare;

                $bind = new Bind($parameters, $name);
                $this->commandQueue[] = $bind;

                $describe = new Describe();
                $this->commandQueue[] = $describe;

                $execute = new Execute();
                $this->commandQueue[] = $execute;

                $sync = new Sync($queryString, $observer);
                $this->commandQueue[] = $sync;

                $this->changeQueueCountInc();

                $this->processQueue();

                return new CallbackDisposable(function () use ($sync) {
                    $this->changeQueueCountDec();
                    if ($this->currentCommand === $sync && $sync->isActive()) {
                        $this->cancelRequest();
                    }
                    $sync->cancel();
                });
            }
        );
    }
Execute statement
@param string $queryString
@param array  $parameters
@return Observable