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
16 public function name() {
17 return $this->info->name;
18 }
19
20 public function tableName() {
21 return $this->tableName;
22 }
23
24 public function defaultValue() {
25 if ( is_string( $this->info->dflt_value ) ) {
26 // Typically quoted
27 if ( preg_match( '/^\'(.*)\'$/', $this->info->dflt_value, $matches ) ) {
28 return str_replace( "''", "'", $matches[1] );
29 }
30 }
31
32 return $this->info->dflt_value;
33 }
34
38 public function isNullable() {
39 return !$this->info->notnull;
40 }
41
42 public function type() {
43 return $this->info->type;
44 }
45}
tableName()
Name of table this field belongs to.
__construct(stdClass $info, string $tableName)
Base for all database-specific classes representing information about database fields.
Definition Field.php:9