X-Git-Url: https://scripts.mit.edu/gitweb/autoinstallsdev/mediawiki.git/blobdiff_plain/19e297c21b10b1b8a3acad5e73fc71dcb35db44a..6932310fd58ebef145fa01eb76edf7150284d8ea:/includes/libs/rdbms/field/PostgresField.php diff --git a/includes/libs/rdbms/field/PostgresField.php b/includes/libs/rdbms/field/PostgresField.php new file mode 100644 index 00000000..600f34a4 --- /dev/null +++ b/includes/libs/rdbms/field/PostgresField.php @@ -0,0 +1,110 @@ +remappedTableName( $table ); + $res = $db->query( + sprintf( $q, + $db->addQuotes( $db->getCoreSchema() ), + $db->addQuotes( $table ), + $db->addQuotes( $field ) + ) + ); + $row = $db->fetchObject( $res ); + if ( !$row ) { + return null; + } + $n = new PostgresField; + $n->type = $row->typname; + $n->nullable = ( $row->attnotnull == 'f' ); + $n->name = $field; + $n->tablename = $table; + $n->max_length = $row->attlen; + $n->deferrable = ( $row->deferrable == 't' ); + $n->deferred = ( $row->deferred == 't' ); + $n->conname = $row->conname; + $n->has_default = ( $row->atthasdef === 't' ); + $n->default = $row->adsrc; + + return $n; + } + + function name() { + return $this->name; + } + + function tableName() { + return $this->tablename; + } + + function type() { + return $this->type; + } + + function isNullable() { + return $this->nullable; + } + + function maxLength() { + return $this->max_length; + } + + function is_deferrable() { + return $this->deferrable; + } + + function is_deferred() { + return $this->deferred; + } + + function conname() { + return $this->conname; + } + + /** + * @since 1.19 + * @return bool|mixed + */ + function defaultValue() { + if ( $this->has_default ) { + return $this->default; + } else { + return false; + } + } +}