1
0
mirror of synced 2024-12-14 23:26:04 +03:00
doctrine2/lib/Doctrine/adodb-hack/drivers/datadict-sqlite.inc.php

139 lines
3.2 KiB
PHP
Raw Normal View History

2006-05-30 13:08:46 +04:00
<?php
/**
V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 4 for best viewing.
Modified 28 August, 2005 for use with ADOdb Lite by Mark Dickenson
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
class ADODB2_sqlite extends ADODB_DataDict {
var $dbtype = 'sqlite';
var $seqField = false;
var $metaTablesSQL = "SELECT name FROM sqlite_master WHERE type='table' ORDER BY name";
function ActualType($meta)
{
switch($meta) {
2006-06-25 22:34:53 +04:00
case 'C': return 'TEXT';
2006-05-30 13:08:46 +04:00
case 'XL':
2006-06-25 22:34:53 +04:00
case 'X': return 'TEXT';
2006-05-30 13:08:46 +04:00
2006-06-25 22:34:53 +04:00
case 'C2': return 'TEXT';
case 'X2': return 'TEXT';
case 'B': return 'BLOB';
2006-05-30 13:08:46 +04:00
case 'D': return 'DATE';
case 'T': return 'DATE';
2006-09-24 16:50:39 +04:00
case 'L': return 'INTEGER';
2006-06-25 22:34:53 +04:00
case 'I': return 'INTEGER';
case 'I1': return 'INTEGER';
case 'I2': return 'INTEGER';
case 'I4': return 'INTEGER';
case 'I8': return 'INTEGER';
2006-05-30 13:08:46 +04:00
2006-06-25 22:34:53 +04:00
case 'F': return 'REAL';
2006-05-30 13:08:46 +04:00
case 'N': return 'DECIMAL';
default:
return $meta;
}
}
2006-06-25 22:34:53 +04:00
// return string must begin with space
function _CreateSuffix($fname,$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned = null)
2006-06-25 22:34:53 +04:00
{
$suffix = '';
if ($funsigned) $suffix .= ' UNSIGNED';
if ($fnotnull) $suffix .= ' NOT NULL';
if (strlen($fdefault)) $suffix .= " DEFAULT $fdefault";
2006-06-25 22:34:53 +04:00
if ($fautoinc) $suffix .= ' PRIMARY KEY AUTOINCREMENT';
if ($fconstraint) $suffix .= ' '.$fconstraint;
return $suffix;
}
function _TableSQL($tabname, $lines,$pkey,$tableoptions)
2006-06-25 22:34:53 +04:00
{
$sql = array();
if (isset($tableoptions['REPLACE']) || isset ($tableoptions['DROP'])) {
$sql[] = sprintf($this->dropTable,$tabname);
if ($this->autoIncrement) {
$sInc = $this->_DropAutoIncrement($tabname);
if ($sInc) $sql[] = $sInc;
}
if ( isset ($tableoptions['DROP']) ) {
return $sql;
}
}
$s = "CREATE TABLE $tabname (\n";
$s .= implode(",\n", $lines);
if (sizeof($pkey)>0 && ! $this->autoIncrement) {
2006-06-25 22:34:53 +04:00
$s .= ",\n PRIMARY KEY (";
$s .= implode(", ",$pkey).")";
}
2006-06-25 22:34:53 +04:00
if (isset($tableoptions['CONSTRAINTS']))
$s .= "\n".$tableoptions['CONSTRAINTS'];
if (isset($tableoptions[$this->upperName.'_CONSTRAINTS']))
$s .= "\n".$tableoptions[$this->upperName.'_CONSTRAINTS'];
$s .= "\n)";
if (isset($tableoptions[$this->upperName])) $s .= $tableoptions[$this->upperName];
$sql[] = $s;
return $sql;
}
2006-05-30 13:08:46 +04:00
function AlterColumnSQL($tabname, $flds, $tableflds='',$tableoptions='')
2006-05-30 13:08:46 +04:00
{
if ($this->debug) $this->outp("AlterColumnSQL not supported");
return array();
}
function DropColumnSQL($tabname, $flds, $tableflds='',$tableoptions='')
2006-05-30 13:08:46 +04:00
{
if ($this->debug) $this->outp("DropColumnSQL not supported");
return array();
}
// function MetaType($t,$len=-1,$fieldobj=false)
// {
// }
// function &MetaTables($ttype=false,$showSchema=false,$mask=false)
// {
// global $ADODB_FETCH_MODE;
// }
// function &MetaColumns($table,$upper=true)
// {
// global $ADODB_FETCH_MODE;
// }
// function MetaPrimaryKeys($table, $owner=false)
// {
// }
// function &MetaIndexes($table, $primary = false, $owner = false)
// {
// }
}