Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

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

   1  <?php
   2  
   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.
  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  	 public $blobAllowsDefaultValue = true;
  29  	 public $blobAllowsNotNull      = true;
  30      
  31  	function ActualType($meta)
  32  	 {
  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
  37  
  38  	 	 case 'C2': return 'VARCHAR'; //  TEXT , TEXT affinity
  39  	 	 case 'X2': return 'LONGTEXT'; //  TEXT , TEXT affinity
  40  
  41  	 	 case 'B': return 'LONGBLOB'; //  TEXT , NONE affinity , BLOB
  42  
  43  	 	 case 'D': return 'DATE'; // NUMERIC , NUMERIC affinity
  44  	 	 case 'T': return 'DATETIME'; // NUMERIC , NUMERIC affinity
  45  	 	 case 'L': return 'TINYINT'; // NUMERIC , INTEGER affinity
  46  
  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
  53  
  54  	 	 case 'F': return 'DOUBLE'; // NUMERIC , REAL affinity
  55  	 	 case 'N': return 'NUMERIC'; // NUMERIC , NUMERIC affinity
  56  	 	 default:
  57  	 	 	 return $meta;
  58  	 	 }
  59  	 }
  60  
  61  	 // return string must begin with space
  62  	function _CreateSuffix($fname,&$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned)
  63  	 {
  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;
  71  	 }
  72  
  73  	function AlterColumnSQL($tabname, $flds, $tableflds='', $tableoptions='')
  74  	 {
  75  	 	 if ($this->debug) ADOConnection::outp("AlterColumnSQL not supported natively by SQLite");
  76  	 	 return array();
  77  	 }
  78  
  79  	function DropColumnSQL($tabname, $flds, $tableflds='', $tableoptions='')
  80  	 {
  81  	 	 if ($this->debug) ADOConnection::outp("DropColumnSQL not supported natively by SQLite");
  82  	 	 return array();
  83  	 }
  84  
  85  	function RenameColumnSQL($tabname,$oldcolumn,$newcolumn,$flds='')
  86  	 {
  87  	 	 if ($this->debug) ADOConnection::outp("RenameColumnSQL not supported natively by SQLite");
  88  	 	 return array();
  89  	 }
  90  
  91  }