Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 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
 
39
		$meta = strtoupper($meta);
40
 
41
		/*
42
		* Add support for custom meta types. We do this
43
		* first, that allows us to override existing types
44
		*/
45
		if (isset($this->connection->customMetaTypes[$meta]))
46
			return $this->connection->customMetaTypes[$meta]['actual'];
47
 
48
		switch(strtoupper($meta)) {
49
		case 'C': return 'VARCHAR'; //  TEXT , TEXT affinity
50
		case 'XL':return 'LONGTEXT'; //  TEXT , TEXT affinity
51
		case 'X': return 'TEXT'; //  TEXT , TEXT affinity
52
 
53
		case 'C2': return 'VARCHAR'; //  TEXT , TEXT affinity
54
		case 'X2': return 'LONGTEXT'; //  TEXT , TEXT affinity
55
 
56
		case 'B': return 'LONGBLOB'; //  TEXT , NONE affinity , BLOB
57
 
58
		case 'D': return 'DATE'; // NUMERIC , NUMERIC affinity
59
		case 'T': return 'DATETIME'; // NUMERIC , NUMERIC affinity
60
		case 'L': return 'TINYINT'; // NUMERIC , INTEGER affinity
61
 
62
		case 'R':
63
		case 'I4':
64
		case 'I': return 'INTEGER'; // NUMERIC , INTEGER affinity
65
		case 'I1': return 'TINYINT'; // NUMERIC , INTEGER affinity
66
		case 'I2': return 'SMALLINT'; // NUMERIC , INTEGER affinity
67
		case 'I8': return 'BIGINT'; // NUMERIC , INTEGER affinity
68
 
69
		case 'F': return 'DOUBLE'; // NUMERIC , REAL affinity
70
		case 'N': return 'NUMERIC'; // NUMERIC , NUMERIC affinity
71
		default:
72
			return $meta;
73
		}
74
	}
75
 
76
	// return string must begin with space
77
	function _CreateSuffix($fname,&$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned)
78
	{
79
		$suffix = '';
80
		if ($funsigned) $suffix .= ' UNSIGNED';
81
		if ($fnotnull) $suffix .= ' NOT NULL';
82
		if (strlen($fdefault)) $suffix .= " DEFAULT $fdefault";
83
		if ($fautoinc) $suffix .= ' AUTOINCREMENT';
84
		if ($fconstraint) $suffix .= ' '.$fconstraint;
85
		return $suffix;
86
	}
87
 
88
	function AlterColumnSQL($tabname, $flds, $tableflds='', $tableoptions='')
89
	{
90
		if ($this->debug) ADOConnection::outp("AlterColumnSQL not supported natively by SQLite");
91
		return array();
92
	}
93
 
94
	function DropColumnSQL($tabname, $flds, $tableflds='', $tableoptions='')
95
	{
96
		if ($this->debug) ADOConnection::outp("DropColumnSQL not supported natively by SQLite");
97
		return array();
98
	}
99
 
100
	function RenameColumnSQL($tabname,$oldcolumn,$newcolumn,$flds='')
101
	{
102
		if ($this->debug) ADOConnection::outp("RenameColumnSQL not supported natively by SQLite");
103
		return array();
104
	}
105
 
106
}