MediaWiki  1.34.0
SQLiteField.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Wikimedia\Rdbms;
4 
5 class SQLiteField implements Field {
6  private $info, $tableName;
7 
8  function __construct( $info, $tableName ) {
9  $this->info = $info;
10  $this->tableName = $tableName;
11  }
12 
13  function name() {
14  return $this->info->name;
15  }
16 
17  function tableName() {
18  return $this->tableName;
19  }
20 
21  function defaultValue() {
22  if ( is_string( $this->info->dflt_value ) ) {
23  // Typically quoted
24  if ( preg_match( '/^\'(.*)\'$/', $this->info->dflt_value, $matches ) ) {
25  return str_replace( "''", "'", $matches[1] );
26  }
27  }
28 
29  return $this->info->dflt_value;
30  }
31 
35  function isNullable() {
36  return !$this->info->notnull;
37  }
38 
39  function type() {
40  return $this->info->type;
41  }
42 }
Wikimedia\Rdbms\SQLiteField
Definition: SQLiteField.php:5
Wikimedia\Rdbms\SQLiteField\defaultValue
defaultValue()
Definition: SQLiteField.php:21
Wikimedia\Rdbms\SQLiteField\type
type()
Database type.
Definition: SQLiteField.php:39
Wikimedia\Rdbms
Definition: ChronologyProtector.php:24
Wikimedia\Rdbms\SQLiteField\$tableName
$tableName
Definition: SQLiteField.php:6
Wikimedia\Rdbms\SQLiteField\__construct
__construct( $info, $tableName)
Definition: SQLiteField.php:8
Wikimedia\Rdbms\SQLiteField\name
name()
Field name.
Definition: SQLiteField.php:13
Wikimedia\Rdbms\SQLiteField\isNullable
isNullable()
Definition: SQLiteField.php:35
Wikimedia\Rdbms\SQLiteField\$info
$info
Definition: SQLiteField.php:6
Wikimedia\Rdbms\SQLiteField\tableName
tableName()
Name of table this field belongs to.
Definition: SQLiteField.php:17
$matches
$matches
Definition: NoLocalSettings.php:24
Wikimedia\Rdbms\Field
Base for all database-specific classes representing information about database fields.
Definition: Field.php:9