TYPO3 CMS  TYPO3_6-2
datadict-sapdb.inc.php
Go to the documentation of this file.
1 <?php
2 
14 // security - hide paths
15 if (!defined('ADODB_DIR')) die();
16 
18 
19  var $databaseType = 'sapdb';
20  var $seqField = false;
21  var $renameColumn = 'RENAME COLUMN %s.%s TO %s';
22 
23  function ActualType($meta)
24  {
25  switch($meta) {
26  case 'C': return 'VARCHAR';
27  case 'XL':
28  case 'X': return 'LONG';
29 
30  case 'C2': return 'VARCHAR UNICODE';
31  case 'X2': return 'LONG UNICODE';
32 
33  case 'B': return 'LONG';
34 
35  case 'D': return 'DATE';
36  case 'TS':
37  case 'T': return 'TIMESTAMP';
38 
39  case 'L': return 'BOOLEAN';
40  case 'I': return 'INTEGER';
41  case 'I1': return 'FIXED(3)';
42  case 'I2': return 'SMALLINT';
43  case 'I4': return 'INTEGER';
44  case 'I8': return 'FIXED(20)';
45 
46  case 'F': return 'FLOAT(38)';
47  case 'N': return 'FIXED';
48  default:
49  return $meta;
50  }
51  }
52 
53  function MetaType($t,$len=-1,$fieldobj=false)
54  {
55  if (is_object($t)) {
56  $fieldobj = $t;
57  $t = $fieldobj->type;
58  $len = $fieldobj->max_length;
59  }
60  static $maxdb_type2adodb = array(
61  'VARCHAR' => 'C',
62  'CHARACTER' => 'C',
63  'LONG' => 'X', // no way to differ between 'X' and 'B' :-(
64  'DATE' => 'D',
65  'TIMESTAMP' => 'T',
66  'BOOLEAN' => 'L',
67  'INTEGER' => 'I4',
68  'SMALLINT' => 'I2',
69  'FLOAT' => 'F',
70  'FIXED' => 'N',
71  );
72  $type = isset($maxdb_type2adodb[$t]) ? $maxdb_type2adodb[$t] : 'C';
73 
74  // convert integer-types simulated with fixed back to integer
75  if ($t == 'FIXED' && !$fieldobj->scale && ($len == 20 || $len == 3)) {
76  $type = $len == 20 ? 'I8' : 'I1';
77  }
78  if ($fieldobj->auto_increment) $type = 'R';
79 
80  return $type;
81  }
82 
83  // return string must begin with space
84  function _CreateSuffix($fname,&$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned)
85  {
86  $suffix = '';
87  if ($funsigned) $suffix .= ' UNSIGNED';
88  if ($fnotnull) $suffix .= ' NOT NULL';
89  if ($fautoinc) $suffix .= ' DEFAULT SERIAL';
90  elseif (strlen($fdefault)) $suffix .= " DEFAULT $fdefault";
91  if ($fconstraint) $suffix .= ' '.$fconstraint;
92  return $suffix;
93  }
94 
95  function AddColumnSQL($tabname, $flds)
96  {
97  $tabname = $this->TableName ($tabname);
98  $sql = array();
99  list($lines,$pkey) = $this->_GenFields($flds);
100  return array( 'ALTER TABLE ' . $tabname . ' ADD (' . implode(', ',$lines) . ')' );
101  }
102 
103  function AlterColumnSQL($tabname, $flds, $tableflds='', $tableoptions='')
104  {
105  $tabname = $this->TableName ($tabname);
106  $sql = array();
107  list($lines,$pkey) = $this->_GenFields($flds);
108  return array( 'ALTER TABLE ' . $tabname . ' MODIFY (' . implode(', ',$lines) . ')' );
109  }
110 
111  function DropColumnSQL($tabname, $flds, $tableflds='', $tableoptions='')
112  {
113  $tabname = $this->TableName ($tabname);
114  if (!is_array($flds)) $flds = explode(',',$flds);
115  foreach($flds as $k => $v) {
116  $flds[$k] = $this->NameQuote($v);
117  }
118  return array( 'ALTER TABLE ' . $tabname . ' DROP (' . implode(', ',$flds) . ')' );
119  }
120 }
_GenFields($flds, $widespacing=false)
$sql
Definition: server.php:82
AddColumnSQL($tabname, $flds)
AlterColumnSQL($tabname, $flds, $tableflds='', $tableoptions='')
die
Definition: index.php:6
_CreateSuffix($fname, &$ftype, $fnotnull, $fdefault, $fautoinc, $fconstraint, $funsigned)
DropColumnSQL($tabname, $flds, $tableflds='', $tableoptions='')
MetaType($t, $len=-1, $fieldobj=false)
NameQuote($name=NULL, $allowBrackets=false)