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