pg_field_type example

/** * Generates an array of objects representing field meta-data. */
    public function getFieldData(): array
    {
        $retVal = [];

        for ($i = 0, $c = $this->getFieldCount()$i < $c$i++) {
            $retVal[$i]             = new stdClass();
            $retVal[$i]->name       = pg_field_name($this->resultID, $i);
            $retVal[$i]->type       = pg_field_type_oid($this->resultID, $i);
            $retVal[$i]->type_name  = pg_field_type($this->resultID, $i);
            $retVal[$i]->max_length = pg_field_size($this->resultID, $i);
            $retVal[$i]->length     = $retVal[$i]->max_length;
            // $retVal[$i]->primary_key = (int)($fieldData[$i]->flags & 2);             // $retVal[$i]->default = $fieldData[$i]->def;         }

        return $retVal;
    }

    /** * Frees the current result. * * @return void */


        $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',
            ];
            if (' (OID: )' === $field['table']) {
                $field['table'] = null;
            }
            if ('-1 bytes' === $field['storage']) {
                $field['storage'] = 'variable size';
            } elseif ('1 bytes' === $field['storage']) {
                $field['storage'] = '1 byte';
            }


        $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',
            ];
            if (' (OID: )' === $field['table']) {
                $field['table'] = null;
            }
            if ('-1 bytes' === $field['storage']) {
                $field['storage'] = 'variable size';
            } elseif ('1 bytes' === $field['storage']) {
                $field['storage'] = '1 byte';
            }
Home | Imprint | This part of the site doesn't use cookies.