MediaWiki master
SQLiteField.php
Go to the documentation of this file.
1<?php
2
3namespace Wikimedia\Rdbms;
4
5use stdClass;
6
7class SQLiteField implements Field {
8 private stdClass $info;
9 private string $tableName;
10
11 public function __construct( stdClass $info, string $tableName ) {
12 $this->info = $info;
13 $this->tableName = $tableName;
14 }
15
17 public function name() {
18 return $this->info->name;
19 }
20
22 public function tableName() {
23 return $this->tableName;
24 }
25
29 public function defaultValue() {
30 if ( is_string( $this->info->dflt_value ) ) {
31 // Typically quoted
32 if ( preg_match( '/^\'(.*)\'$/', $this->info->dflt_value, $matches ) ) {
33 return str_replace( "''", "'", $matches[1] );
34 }
35 }
36
37 return $this->info->dflt_value;
38 }
39
43 public function isNullable() {
44 return !$this->info->notnull;
45 }
46
48 public function type() {
49 return $this->info->type;
50 }
51}
type()
Database type.string
tableName()
Name of table this field belongs to.string
name()
Field name.string
__construct(stdClass $info, string $tableName)
Base for all database-specific classes representing information about database fields.
Definition Field.php:9