pg_last_oid example

$a['status'] = new ConstStub(self::RESULT_STATUS[$a['status']]$a['status']);
        }
        $a['command-completion tag'] = pg_result_status($result, \PGSQL_STATUS_STRING);

        if (-1 === $a['num rows']) {
            foreach (self::DIAG_CODES as $k => $v) {
                $a['error'][$k] = pg_result_error_field($result$v);
            }
        }

        $a['affected rows'] = pg_affected_rows($result);
        $a['last OID'] = pg_last_oid($result);

        $fields = pg_num_fields($result);

        for ($i = 0; $i < $fields; ++$i) {
            $field = [
                'name' => pg_field_name($result$i),
                'table' => sprintf('%s (OID: %s)', pg_field_table($result$i)pg_field_table($result$i, true)),
                'type' => sprintf('%s (OID: %s)', pg_field_type($result$i)pg_field_type_oid($result$i)),
                'nullable' => (bool) pg_field_is_null($result$i),
                'storage' => pg_field_size($result$i).' bytes',
                'display' => pg_field_prtlen($result$i).' chars',
            ];
$a['status'] = new ConstStub(self::RESULT_STATUS[$a['status']]$a['status']);
        }
        $a['command-completion tag'] = pg_result_status($result, \PGSQL_STATUS_STRING);

        if (-1 === $a['num rows']) {
            foreach (self::DIAG_CODES as $k => $v) {
                $a['error'][$k] = pg_result_error_field($result$v);
            }
        }

        $a['affected rows'] = pg_affected_rows($result);
        $a['last OID'] = pg_last_oid($result);

        $fields = pg_num_fields($result);

        for ($i = 0; $i < $fields; ++$i) {
            $field = [
                'name' => pg_field_name($result$i),
                'table' => sprintf('%s (OID: %s)', pg_field_table($result$i)pg_field_table($result$i, true)),
                'type' => sprintf('%s (OID: %s)', pg_field_type($result$i)pg_field_type_oid($result$i)),
                'nullable' => (bool) pg_field_is_null($result$i),
                'storage' => pg_field_size($result$i).' bytes',
                'display' => pg_field_prtlen($result$i).' chars',
            ];
$sql   = "SELECT pg_get_serial_sequence('{$table}', '{$column}') AS seq";
                $query = $this->query($sql);
                $query = $query->getRow();
                $seq   = $query->seq;
            } else {
                // seq_name passed in table parameter                 $seq = $table;
            }

            $sql = "SELECT CURRVAL('{$seq}') AS ins_id";
        } else {
            return pg_last_oid($this->resultID);
        }

        $query = $this->query($sql);
        $query = $query->getRow();

        return (int) $query->ins_id;
    }

    /** * Build a DSN from the provided parameters */
    
Home | Imprint | This part of the site doesn't use cookies.