"TYPO3 4.0.1: typo3_src-4.0.1/typo3/sysext/adodb/adodb/drivers/adodb-sapdb.inc.php Source File", "datetime" => "Sat Dec 2 19:22:26 2006", "date" => "2 Dec 2006", "doxygenversion" => "1.4.6", "projectname" => "TYPO3 4.0.1", "projectnumber" => "4.0.1" ); get_header($doxygen_vars); ?>
00001 <?php 00002 /* 00003 V4.90 8 June 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved. 00004 Released under both BSD license and Lesser GPL library license. 00005 Whenever there is any discrepancy between the two licenses, 00006 the BSD license will take precedence. 00007 Set tabs to 4 for best viewing. 00008 00009 Latest version is available at http://adodb.sourceforge.net 00010 00011 SAPDB data driver. Requires ODBC. 00012 00013 */ 00014 00015 // security - hide paths 00016 if (!defined('ADODB_DIR')) die(); 00017 00018 if (!defined('_ADODB_ODBC_LAYER')) { 00019 include(ADODB_DIR."/drivers/adodb-odbc.inc.php"); 00020 } 00021 if (!defined('ADODB_SAPDB')){ 00022 define('ADODB_SAPDB',1); 00023 00024 class ADODB_SAPDB extends ADODB_odbc { 00025 var $databaseType = "sapdb"; 00026 var $concat_operator = '||'; 00027 var $sysDate = 'DATE'; 00028 var $sysTimeStamp = 'TIMESTAMP'; 00029 var $fmtDate = "'Y-m-d'"; 00030 var $fmtTimeStamp = "'Y-m-d H:i:s'"; 00031 var $hasInsertId = true; 00032 var $_bindInputArray = true; 00033 00034 function ADODB_SAPDB() 00035 { 00036 //if (strncmp(PHP_OS,'WIN',3) === 0) $this->curmode = SQL_CUR_USE_ODBC; 00037 $this->ADODB_odbc(); 00038 } 00039 00040 function ServerInfo() 00041 { 00042 $info = ADODB_odbc::ServerInfo(); 00043 if (!$info['version'] && preg_match('/([0-9.]+)/',$info['description'],$matches)) { 00044 $info['version'] = $matches[1]; 00045 } 00046 return $info; 00047 } 00048 00049 function MetaPrimaryKeys($table) 00050 { 00051 $table = $this->Quote(strtoupper($table)); 00052 00053 return $this->GetCol("SELECT columnname FROM COLUMNS WHERE tablename=$table AND mode='KEY' ORDER BY pos"); 00054 } 00055 00056 function &MetaIndexes ($table, $primary = FALSE) 00057 { 00058 $table = $this->Quote(strtoupper($table)); 00059 00060 $sql = "SELECT INDEXNAME,TYPE,COLUMNNAME FROM INDEXCOLUMNS ". 00061 " WHERE TABLENAME=$table". 00062 " ORDER BY INDEXNAME,COLUMNNO"; 00063 00064 global $ADODB_FETCH_MODE; 00065 $save = $ADODB_FETCH_MODE; 00066 $ADODB_FETCH_MODE = ADODB_FETCH_NUM; 00067 if ($this->fetchMode !== FALSE) { 00068 $savem = $this->SetFetchMode(FALSE); 00069 } 00070 00071 $rs = $this->Execute($sql); 00072 if (isset($savem)) { 00073 $this->SetFetchMode($savem); 00074 } 00075 $ADODB_FETCH_MODE = $save; 00076 00077 if (!is_object($rs)) { 00078 return FALSE; 00079 } 00080 00081 $indexes = array(); 00082 while ($row = $rs->FetchRow()) { 00083 $indexes[$row[0]]['unique'] = $row[1] == 'UNIQUE'; 00084 $indexes[$row[0]]['columns'][] = $row[2]; 00085 } 00086 if ($primary) { 00087 $indexes['SYSPRIMARYKEYINDEX'] = array( 00088 'unique' => True, // by definition 00089 'columns' => $this->GetCol("SELECT columnname FROM COLUMNS WHERE tablename=$table AND mode='KEY' ORDER BY pos"), 00090 ); 00091 } 00092 return $indexes; 00093 } 00094 00095 function &MetaColumns ($table) 00096 { 00097 global $ADODB_FETCH_MODE; 00098 $save = $ADODB_FETCH_MODE; 00099 $ADODB_FETCH_MODE = ADODB_FETCH_NUM; 00100 if ($this->fetchMode !== FALSE) { 00101 $savem = $this->SetFetchMode(FALSE); 00102 } 00103 $table = $this->Quote(strtoupper($table)); 00104 00105 $retarr = array(); 00106 foreach($this->GetAll("SELECT COLUMNNAME,DATATYPE,LEN,DEC,NULLABLE,MODE,\"DEFAULT\",CASE WHEN \"DEFAULT\" IS NULL THEN 0 ELSE 1 END AS HAS_DEFAULT FROM COLUMNS WHERE tablename=$table ORDER BY pos") as $column) 00107 { 00108 $fld = new ADOFieldObject(); 00109 $fld->name = $column[0]; 00110 $fld->type = $column[1]; 00111 $fld->max_length = $fld->type == 'LONG' ? 2147483647 : $column[2]; 00112 $fld->scale = $column[3]; 00113 $fld->not_null = $column[4] == 'NO'; 00114 $fld->primary_key = $column[5] == 'KEY'; 00115 if ($fld->has_default = $column[7]) { 00116 if ($fld->primary_key && $column[6] == 'DEFAULT SERIAL (1)') { 00117 $fld->auto_increment = true; 00118 $fld->has_default = false; 00119 } else { 00120 $fld->default_value = $column[6]; 00121 switch($fld->type) { 00122 case 'VARCHAR': 00123 case 'CHARACTER': 00124 case 'LONG': 00125 $fld->default_value = $column[6]; 00126 break; 00127 default: 00128 $fld->default_value = trim($column[6]); 00129 break; 00130 } 00131 } 00132 } 00133 $retarr[$fld->name] = $fld; 00134 } 00135 if (isset($savem)) { 00136 $this->SetFetchMode($savem); 00137 } 00138 $ADODB_FETCH_MODE = $save; 00139 00140 return $retarr; 00141 } 00142 00143 function MetaColumnNames($table) 00144 { 00145 $table = $this->Quote(strtoupper($table)); 00146 00147 return $this->GetCol("SELECT columnname FROM COLUMNS WHERE tablename=$table ORDER BY pos"); 00148 } 00149 00150 // unlike it seems, this depends on the db-session and works in a multiuser environment 00151 function _insertid($table,$column) 00152 { 00153 return empty($table) ? False : $this->GetOne("SELECT $table.CURRVAL FROM DUAL"); 00154 } 00155 00156 /* 00157 SelectLimit implementation problems: 00158 00159 The following will return random 10 rows as order by performed after "WHERE rowno<10" 00160 which is not ideal... 00161 00162 select * from table where rowno < 10 order by 1 00163 00164 This means that we have to use the adoconnection base class SelectLimit when 00165 there is an "order by". 00166 00167 See http://listserv.sap.com/pipermail/sapdb.general/2002-January/010405.html 00168 */ 00169 00170 }; 00171 00172 00173 class ADORecordSet_sapdb extends ADORecordSet_odbc { 00174 00175 var $databaseType = "sapdb"; 00176 00177 function ADORecordSet_sapdb($id,$mode=false) 00178 { 00179 $this->ADORecordSet_odbc($id,$mode); 00180 } 00181 } 00182 00183 } //define 00184 ?>