"TYPO3 4.0.1: typo3_src-4.0.1/typo3/sysext/adodb/adodb/datadict/datadict-sapdb.inc.php Source File", "datetime" => "Sat Dec 2 19:22:25 2006", "date" => "2 Dec 2006", "doxygenversion" => "1.4.6", "projectname" => "TYPO3 4.0.1", "projectnumber" => "4.0.1" ); get_header($doxygen_vars); ?>

datadict-sapdb.inc.php

00001 <?php
00002 
00014 // security - hide paths
00015 if (!defined('ADODB_DIR')) die();
00016 
00017 class ADODB2_sapdb extends ADODB_DataDict {
00018         
00019         var $databaseType = 'sapdb';
00020         var $seqField = false;  
00021         var $renameColumn = 'RENAME COLUMN %s.%s TO %s';
00022         
00023         function ActualType($meta)
00024         {
00025                 switch($meta) {
00026                 case 'C': return 'VARCHAR';
00027                 case 'XL':
00028                 case 'X': return 'LONG';
00029                 
00030                 case 'C2': return 'VARCHAR UNICODE';
00031                 case 'X2': return 'LONG UNICODE';
00032                 
00033                 case 'B': return 'LONG';
00034                         
00035                 case 'D': return 'DATE';
00036                 case 'T': return 'TIMESTAMP';
00037                 
00038                 case 'L': return 'BOOLEAN';
00039                 case 'I': return 'INTEGER';
00040                 case 'I1': return 'FIXED(3)';
00041                 case 'I2': return 'SMALLINT';
00042                 case 'I4': return 'INTEGER';
00043                 case 'I8': return 'FIXED(20)';
00044                 
00045                 case 'F': return 'FLOAT(38)';
00046                 case 'N': return 'FIXED';
00047                 default:
00048                         return $meta;
00049                 }
00050         }
00051         
00052         function MetaType($t,$len=-1,$fieldobj=false)
00053         {
00054                 if (is_object($t)) {
00055                         $fieldobj = $t;
00056                         $t = $fieldobj->type;
00057                         $len = $fieldobj->max_length;
00058                 }
00059                 static $maxdb_type2adodb = array(
00060                         'VARCHAR'       => 'C',
00061                         'CHARACTER'     => 'C',
00062                         'LONG'          => 'X',         // no way to differ between 'X' and 'B' :-(
00063                         'DATE'          => 'D',
00064                         'TIMESTAMP'     => 'T',
00065                         'BOOLEAN'       => 'L',
00066                         'INTEGER'       => 'I4',
00067                         'SMALLINT'      => 'I2',
00068                         'FLOAT'         => 'F',
00069                         'FIXED'         => 'N',
00070                 );
00071                 $type = isset($maxdb_type2adodb[$t]) ? $maxdb_type2adodb[$t] : 'C';
00072 
00073                 // convert integer-types simulated with fixed back to integer
00074                 if ($t == 'FIXED' && !$fieldobj->scale && ($len == 20 || $len == 3)) {
00075                         $type = $len == 20 ? 'I8' : 'I1';
00076                 }
00077                 if ($fieldobj->auto_increment) $type = 'R';
00078 
00079                 return $type;
00080         }
00081         
00082         // return string must begin with space
00083         function _CreateSuffix($fname,$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned)
00084         {       
00085                 $suffix = '';
00086                 if ($funsigned) $suffix .= ' UNSIGNED';
00087                 if ($fnotnull) $suffix .= ' NOT NULL';
00088                 if ($fautoinc) $suffix .= ' DEFAULT SERIAL';
00089                 elseif (strlen($fdefault)) $suffix .= " DEFAULT $fdefault";
00090                 if ($fconstraint) $suffix .= ' '.$fconstraint;
00091                 return $suffix;
00092         }
00093 
00094         function AddColumnSQL($tabname, $flds)
00095         {
00096                 $tabname = $this->TableName ($tabname);
00097                 $sql = array();
00098                 list($lines,$pkey) = $this->_GenFields($flds);
00099                 return array( 'ALTER TABLE ' . $tabname . ' ADD (' . implode(', ',$lines) . ')' );
00100         }
00101         
00102         function AlterColumnSQL($tabname, $flds)
00103         {
00104                 $tabname = $this->TableName ($tabname);
00105                 $sql = array();
00106                 list($lines,$pkey) = $this->_GenFields($flds);
00107                 return array( 'ALTER TABLE ' . $tabname . ' MODIFY (' . implode(', ',$lines) . ')' );
00108         }
00109 
00110         function DropColumnSQL($tabname, $flds)
00111         {
00112                 $tabname = $this->TableName ($tabname);
00113                 if (!is_array($flds)) $flds = explode(',',$flds);
00114                 foreach($flds as $k => $v) {
00115                         $flds[$k] = $this->NameQuote($v);
00116                 }
00117                 return array( 'ALTER TABLE ' . $tabname . ' DROP (' . implode(', ',$flds) . ')' );
00118         }       
00119 }
00120 
00121 ?>