Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 3.9.x will end* 10 May 2021 (12 months).
  • Bug fixes for security issues in 3.9.x will end* 8 May 2023 (36 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

Differences Between: [Versions 39 and 311] [Versions 39 and 400] [Versions 39 and 401] [Versions 39 and 402] [Versions 39 and 403]

   1  <?php
   2  
   3  /**
   4    @version   v5.20.16  12-Jan-2020
   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.
  10  
  11    Set tabs to 4 for best viewing.
  12  
  13  	 SQLite datadict Andrei Besleaga
  14  
  15  */
  16  
  17  // security - hide paths
  18  if (!defined('ADODB_DIR')) die();
  19  
  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';
  27  
  28  
  29  
  30  	function ActualType($meta)
  31  	 {
  32  	 	 switch(strtoupper($meta)) {
  33  	 	 case 'C': return 'VARCHAR'; //  TEXT , TEXT affinity
  34  	 	 case 'XL':return 'LONGTEXT'; //  TEXT , TEXT affinity
  35  	 	 case 'X': return 'TEXT'; //  TEXT , TEXT affinity
  36  
  37  	 	 case 'C2': return 'VARCHAR'; //  TEXT , TEXT affinity
  38  	 	 case 'X2': return 'LONGTEXT'; //  TEXT , TEXT affinity
  39  
  40  	 	 case 'B': return 'LONGBLOB'; //  TEXT , NONE affinity , BLOB
  41  
  42  	 	 case 'D': return 'DATE'; // NUMERIC , NUMERIC affinity
  43  	 	 case 'T': return 'DATETIME'; // NUMERIC , NUMERIC affinity
  44  	 	 case 'L': return 'TINYINT'; // NUMERIC , INTEGER affinity
  45  
  46  	 	 case 'R':
  47  	 	 case 'I4':
  48  	 	 case 'I': return 'INTEGER'; // NUMERIC , INTEGER affinity
  49  	 	 case 'I1': return 'TINYINT'; // NUMERIC , INTEGER affinity
  50  	 	 case 'I2': return 'SMALLINT'; // NUMERIC , INTEGER affinity
  51  	 	 case 'I8': return 'BIGINT'; // NUMERIC , INTEGER affinity
  52  
  53  	 	 case 'F': return 'DOUBLE'; // NUMERIC , REAL affinity
  54  	 	 case 'N': return 'NUMERIC'; // NUMERIC , NUMERIC affinity
  55  	 	 default:
  56  	 	 	 return $meta;
  57  	 	 }
  58  	 }
  59  
  60  	 // return string must begin with space
  61  	function _CreateSuffix($fname,$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned)
  62  	 {
  63  	 	 $suffix = '';
  64  	 	 if ($funsigned) $suffix .= ' UNSIGNED';
  65  	 	 if ($fnotnull) $suffix .= ' NOT NULL';
  66  	 	 if (strlen($fdefault)) $suffix .= " DEFAULT $fdefault";
  67  	 	 if ($fautoinc) $suffix .= ' AUTOINCREMENT';
  68  	 	 if ($fconstraint) $suffix .= ' '.$fconstraint;
  69  	 	 return $suffix;
  70  	 }
  71  
  72  	function AlterColumnSQL($tabname, $flds, $tableflds='', $tableoptions='')
  73  	 {
  74  	 	 if ($this->debug) ADOConnection::outp("AlterColumnSQL not supported natively by SQLite");
  75  	 	 return array();
  76  	 }
  77  
  78  	function DropColumnSQL($tabname, $flds, $tableflds='', $tableoptions='')
  79  	 {
  80  	 	 if ($this->debug) ADOConnection::outp("DropColumnSQL not supported natively by SQLite");
  81  	 	 return array();
  82  	 }
  83  
  84  	function RenameColumnSQL($tabname,$oldcolumn,$newcolumn,$flds='')
  85  	 {
  86  	 	 if ($this->debug) ADOConnection::outp("RenameColumnSQL not supported natively by SQLite");
  87  	 	 return array();
  88  	 }
  89  
  90  }