SQLiteField.php 724 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace Wikimedia\Rdbms;
  3. class SQLiteField implements Field {
  4. private $info, $tableName;
  5. function __construct( $info, $tableName ) {
  6. $this->info = $info;
  7. $this->tableName = $tableName;
  8. }
  9. function name() {
  10. return $this->info->name;
  11. }
  12. function tableName() {
  13. return $this->tableName;
  14. }
  15. function defaultValue() {
  16. if ( is_string( $this->info->dflt_value ) ) {
  17. // Typically quoted
  18. if ( preg_match( '/^\'(.*)\'$/', $this->info->dflt_value, $matches ) ) {
  19. return str_replace( "''", "'", $matches[1] );
  20. }
  21. }
  22. return $this->info->dflt_value;
  23. }
  24. /**
  25. * @return bool
  26. */
  27. function isNullable() {
  28. return !$this->info->notnull;
  29. }
  30. function type() {
  31. return $this->info->type;
  32. }
  33. }