Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

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

   1  <?php
   2  /**
   3   * Data Dictionary for SQLite.
   4   *
   5   * This file is part of ADOdb, a Database Abstraction Layer library for PHP.
   6   *
   7   * @package ADOdb
   8   * @link https://adodb.org Project's web site and documentation
   9   * @link https://github.com/ADOdb/ADOdb Source code and issue tracker
  10   *
  11   * The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
  12   * and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
  13   * any later version. This means you can use it in proprietary products.
  14   * See the LICENSE.md file distributed with this source code for details.
  15   * @license BSD-3-Clause
  16   * @license LGPL-2.1-or-later
  17   *
  18   * @copyright 2000-2013 John Lim
  19   * @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
  20   */
  21  
  22  // security - hide paths
  23  if (!defined('ADODB_DIR')) die();
  24  
  25  class ADODB2_sqlite extends ADODB_DataDict {
  26  	 var $databaseType = 'sqlite';
  27  	 var $seqField = false;
  28  	 var $addCol=' ADD COLUMN';
  29  	 var $dropTable = 'DROP TABLE IF EXISTS %s';
  30  	 var $dropIndex = 'DROP INDEX IF EXISTS %s';
  31  	 var $renameTable = 'ALTER TABLE %s RENAME TO %s';
  32  
  33  	 public $blobAllowsDefaultValue = true;
  34  	 public $blobAllowsNotNull      = true;
  35      
  36  	function ActualType($meta)
  37  	 {
  38  	 	 switch(strtoupper($meta)) {
  39  	 	 case 'C': return 'VARCHAR'; //  TEXT , TEXT affinity
  40  	 	 case 'XL':return 'LONGTEXT'; //  TEXT , TEXT affinity
  41  	 	 case 'X': return 'TEXT'; //  TEXT , TEXT affinity
  42  
  43  	 	 case 'C2': return 'VARCHAR'; //  TEXT , TEXT affinity
  44  	 	 case 'X2': return 'LONGTEXT'; //  TEXT , TEXT affinity
  45  
  46  	 	 case 'B': return 'LONGBLOB'; //  TEXT , NONE affinity , BLOB
  47  
  48  	 	 case 'D': return 'DATE'; // NUMERIC , NUMERIC affinity
  49  	 	 case 'T': return 'DATETIME'; // NUMERIC , NUMERIC affinity
  50  	 	 case 'L': return 'TINYINT'; // NUMERIC , INTEGER affinity
  51  
  52  	 	 case 'R':
  53  	 	 case 'I4':
  54  	 	 case 'I': return 'INTEGER'; // NUMERIC , INTEGER affinity
  55  	 	 case 'I1': return 'TINYINT'; // NUMERIC , INTEGER affinity
  56  	 	 case 'I2': return 'SMALLINT'; // NUMERIC , INTEGER affinity
  57  	 	 case 'I8': return 'BIGINT'; // NUMERIC , INTEGER affinity
  58  
  59  	 	 case 'F': return 'DOUBLE'; // NUMERIC , REAL affinity
  60  	 	 case 'N': return 'NUMERIC'; // NUMERIC , NUMERIC affinity
  61  	 	 default:
  62  	 	 	 return $meta;
  63  	 	 }
  64  	 }
  65  
  66  	 // return string must begin with space
  67  	function _CreateSuffix($fname,&$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned)
  68  	 {
  69  	 	 $suffix = '';
  70  	 	 if ($funsigned) $suffix .= ' UNSIGNED';
  71  	 	 if ($fnotnull) $suffix .= ' NOT NULL';
  72  	 	 if (strlen($fdefault)) $suffix .= " DEFAULT $fdefault";
  73  	 	 if ($fautoinc) $suffix .= ' AUTOINCREMENT';
  74  	 	 if ($fconstraint) $suffix .= ' '.$fconstraint;
  75  	 	 return $suffix;
  76  	 }
  77  
  78  	function AlterColumnSQL($tabname, $flds, $tableflds='', $tableoptions='')
  79  	 {
  80  	 	 if ($this->debug) ADOConnection::outp("AlterColumnSQL not supported natively by SQLite");
  81  	 	 return array();
  82  	 }
  83  
  84  	function DropColumnSQL($tabname, $flds, $tableflds='', $tableoptions='')
  85  	 {
  86  	 	 if ($this->debug) ADOConnection::outp("DropColumnSQL not supported natively by SQLite");
  87  	 	 return array();
  88  	 }
  89  
  90  	function RenameColumnSQL($tabname,$oldcolumn,$newcolumn,$flds='')
  91  	 {
  92  	 	 if ($this->debug) ADOConnection::outp("RenameColumnSQL not supported natively by SQLite");
  93  	 	 return array();
  94  	 }
  95  
  96  }