updated adodb package to work with php 7.1
[openemr.git] / vendor / adodb / adodb-php / datadict / datadict-sapdb.inc.php
blobfbf931c736be66df1939b49fb455348e2366081a
1 <?php
3 /**
4 @version v5.20.9 21-Dec-2016
5 @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
6 @copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
7 Released under both BSD license and Lesser GPL library license.
8 Whenever there is any discrepancy between the two licenses,
9 the BSD license will take precedence.
11 Set tabs to 4 for best viewing.
13 Modified from datadict-generic.inc.php for sapdb by RalfBecker-AT-outdoor-training.de
16 // security - hide paths
17 if (!defined('ADODB_DIR')) die();
19 class ADODB2_sapdb extends ADODB_DataDict {
21 var $databaseType = 'sapdb';
22 var $seqField = false;
23 var $renameColumn = 'RENAME COLUMN %s.%s TO %s';
25 function ActualType($meta)
27 switch($meta) {
28 case 'C': return 'VARCHAR';
29 case 'XL':
30 case 'X': return 'LONG';
32 case 'C2': return 'VARCHAR UNICODE';
33 case 'X2': return 'LONG UNICODE';
35 case 'B': return 'LONG';
37 case 'D': return 'DATE';
38 case 'TS':
39 case 'T': return 'TIMESTAMP';
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)';
48 case 'F': return 'FLOAT(38)';
49 case 'N': return 'FIXED';
50 default:
51 return $meta;
55 function MetaType($t,$len=-1,$fieldobj=false)
57 if (is_object($t)) {
58 $fieldobj = $t;
59 $t = $fieldobj->type;
60 $len = $fieldobj->max_length;
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',
74 $type = isset($maxdb_type2adodb[$t]) ? $maxdb_type2adodb[$t] : 'C';
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';
80 if ($fieldobj->auto_increment) $type = 'R';
82 return $type;
85 // return string must begin with space
86 function _CreateSuffix($fname,&$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned)
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;
97 function AddColumnSQL($tabname, $flds)
99 $tabname = $this->TableName ($tabname);
100 $sql = array();
101 list($lines,$pkey) = $this->_GenFields($flds);
102 return array( 'ALTER TABLE ' . $tabname . ' ADD (' . implode(', ',$lines) . ')' );
105 function AlterColumnSQL($tabname, $flds, $tableflds='', $tableoptions='')
107 $tabname = $this->TableName ($tabname);
108 $sql = array();
109 list($lines,$pkey) = $this->_GenFields($flds);
110 return array( 'ALTER TABLE ' . $tabname . ' MODIFY (' . implode(', ',$lines) . ')' );
113 function DropColumnSQL($tabname, $flds, $tableflds='',$tableoptions='')
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);
120 return array( 'ALTER TABLE ' . $tabname . ' DROP (' . implode(', ',$flds) . ')' );