weekly release 3.11.8+
[moodle.git] / lib / adodb / datadict / datadict-sqlite.inc.php
blob12a68d1fa65550fb4f94a054188698546bbacdf5
1 <?php
3 /**
4 @version v5.21.0 2021-02-27
5 @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
6 @copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
7 Released under both BSD license and Lesser GPL library license.
8 Whenever there is any discrepancy between the two licenses,
9 the BSD license will take precedence.
11 Set tabs to 4 for best viewing.
13 SQLite datadict Andrei Besleaga
17 // security - hide paths
18 if (!defined('ADODB_DIR')) die();
20 class ADODB2_sqlite extends ADODB_DataDict {
21 var $databaseType = 'sqlite';
22 var $seqField = false;
23 var $addCol=' ADD COLUMN';
24 var $dropTable = 'DROP TABLE IF EXISTS %s';
25 var $dropIndex = 'DROP INDEX IF EXISTS %s';
26 var $renameTable = 'ALTER TABLE %s RENAME TO %s';
28 public $blobAllowsDefaultValue = true;
29 public $blobAllowsNotNull = true;
31 function ActualType($meta)
33 switch(strtoupper($meta)) {
34 case 'C': return 'VARCHAR'; // TEXT , TEXT affinity
35 case 'XL':return 'LONGTEXT'; // TEXT , TEXT affinity
36 case 'X': return 'TEXT'; // TEXT , TEXT affinity
38 case 'C2': return 'VARCHAR'; // TEXT , TEXT affinity
39 case 'X2': return 'LONGTEXT'; // TEXT , TEXT affinity
41 case 'B': return 'LONGBLOB'; // TEXT , NONE affinity , BLOB
43 case 'D': return 'DATE'; // NUMERIC , NUMERIC affinity
44 case 'T': return 'DATETIME'; // NUMERIC , NUMERIC affinity
45 case 'L': return 'TINYINT'; // NUMERIC , INTEGER affinity
47 case 'R':
48 case 'I4':
49 case 'I': return 'INTEGER'; // NUMERIC , INTEGER affinity
50 case 'I1': return 'TINYINT'; // NUMERIC , INTEGER affinity
51 case 'I2': return 'SMALLINT'; // NUMERIC , INTEGER affinity
52 case 'I8': return 'BIGINT'; // NUMERIC , INTEGER affinity
54 case 'F': return 'DOUBLE'; // NUMERIC , REAL affinity
55 case 'N': return 'NUMERIC'; // NUMERIC , NUMERIC affinity
56 default:
57 return $meta;
61 // return string must begin with space
62 function _CreateSuffix($fname,&$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned)
64 $suffix = '';
65 if ($funsigned) $suffix .= ' UNSIGNED';
66 if ($fnotnull) $suffix .= ' NOT NULL';
67 if (strlen($fdefault)) $suffix .= " DEFAULT $fdefault";
68 if ($fautoinc) $suffix .= ' AUTOINCREMENT';
69 if ($fconstraint) $suffix .= ' '.$fconstraint;
70 return $suffix;
73 function AlterColumnSQL($tabname, $flds, $tableflds='', $tableoptions='')
75 if ($this->debug) ADOConnection::outp("AlterColumnSQL not supported natively by SQLite");
76 return array();
79 function DropColumnSQL($tabname, $flds, $tableflds='', $tableoptions='')
81 if ($this->debug) ADOConnection::outp("DropColumnSQL not supported natively by SQLite");
82 return array();
85 function RenameColumnSQL($tabname,$oldcolumn,$newcolumn,$flds='')
87 if ($this->debug) ADOConnection::outp("RenameColumnSQL not supported natively by SQLite");
88 return array();