Changeset 34 for trunk/phpgwapi/inc/adodb/drivers/adodb-sapdb.inc.php
- Timestamp:
- 06/29/07 15:17:46 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/phpgwapi/inc/adodb/drivers/adodb-sapdb.inc.php
r2 r34 1 1 <?php 2 2 /* 3 V4. 51 29 July 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.3 V4.94 23 Jan 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved. 4 4 Released under both BSD license and Lesser GPL library license. 5 5 Whenever there is any discrepancy between the two licenses, … … 27 27 var $sysDate = 'DATE'; 28 28 var $sysTimeStamp = 'TIMESTAMP'; 29 var $fmtDate = "\\D\\A\\T\\E('Y-m-d')"; /// used by DBDate() as the default date format used by the database 30 var $fmtTimeStamp = "\\T\\I\\M\\E\\S\\T\\A\\M\\P('Y-m-d','H:i:s')"; /// used by DBTimeStamp as the default timestamp fmt. 29 var $fmtDate = "'Y-m-d'"; /// used by DBDate() as the default date format used by the database 30 var $fmtTimeStamp = "'Y-m-d H:i:s'"; /// used by DBTimeStamp as the default timestamp fmt. 31 var $hasInsertId = true; 32 var $_bindInputArray = true; 31 33 32 34 function ADODB_SAPDB() … … 36 38 } 37 39 40 function ServerInfo() 41 { 42 $info = ADODB_odbc::ServerInfo(); 43 if (!$info['version'] && preg_match('/([0-9.]+)/',$info['description'],$matches)) { 44 $info['version'] = $matches[1]; 45 } 46 return $info; 47 } 48 49 function MetaPrimaryKeys($table) 50 { 51 $table = $this->Quote(strtoupper($table)); 52 53 return $this->GetCol("SELECT columnname FROM COLUMNS WHERE tablename=$table AND mode='KEY' ORDER BY pos"); 54 } 55 56 function &MetaIndexes ($table, $primary = FALSE) 57 { 58 $table = $this->Quote(strtoupper($table)); 59 60 $sql = "SELECT INDEXNAME,TYPE,COLUMNNAME FROM INDEXCOLUMNS ". 61 " WHERE TABLENAME=$table". 62 " ORDER BY INDEXNAME,COLUMNNO"; 63 64 global $ADODB_FETCH_MODE; 65 $save = $ADODB_FETCH_MODE; 66 $ADODB_FETCH_MODE = ADODB_FETCH_NUM; 67 if ($this->fetchMode !== FALSE) { 68 $savem = $this->SetFetchMode(FALSE); 69 } 70 71 $rs = $this->Execute($sql); 72 if (isset($savem)) { 73 $this->SetFetchMode($savem); 74 } 75 $ADODB_FETCH_MODE = $save; 76 77 if (!is_object($rs)) { 78 return FALSE; 79 } 80 81 $indexes = array(); 82 while ($row = $rs->FetchRow()) { 83 $indexes[$row[0]]['unique'] = $row[1] == 'UNIQUE'; 84 $indexes[$row[0]]['columns'][] = $row[2]; 85 } 86 if ($primary) { 87 $indexes['SYSPRIMARYKEYINDEX'] = array( 88 'unique' => True, // by definition 89 'columns' => $this->GetCol("SELECT columnname FROM COLUMNS WHERE tablename=$table AND mode='KEY' ORDER BY pos"), 90 ); 91 } 92 return $indexes; 93 } 94 95 function &MetaColumns ($table) 96 { 97 global $ADODB_FETCH_MODE; 98 $save = $ADODB_FETCH_MODE; 99 $ADODB_FETCH_MODE = ADODB_FETCH_NUM; 100 if ($this->fetchMode !== FALSE) { 101 $savem = $this->SetFetchMode(FALSE); 102 } 103 $table = $this->Quote(strtoupper($table)); 104 105 $retarr = array(); 106 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) 107 { 108 $fld = new ADOFieldObject(); 109 $fld->name = $column[0]; 110 $fld->type = $column[1]; 111 $fld->max_length = $fld->type == 'LONG' ? 2147483647 : $column[2]; 112 $fld->scale = $column[3]; 113 $fld->not_null = $column[4] == 'NO'; 114 $fld->primary_key = $column[5] == 'KEY'; 115 if ($fld->has_default = $column[7]) { 116 if ($fld->primary_key && $column[6] == 'DEFAULT SERIAL (1)') { 117 $fld->auto_increment = true; 118 $fld->has_default = false; 119 } else { 120 $fld->default_value = $column[6]; 121 switch($fld->type) { 122 case 'VARCHAR': 123 case 'CHARACTER': 124 case 'LONG': 125 $fld->default_value = $column[6]; 126 break; 127 default: 128 $fld->default_value = trim($column[6]); 129 break; 130 } 131 } 132 } 133 $retarr[$fld->name] = $fld; 134 } 135 if (isset($savem)) { 136 $this->SetFetchMode($savem); 137 } 138 $ADODB_FETCH_MODE = $save; 139 140 return $retarr; 141 } 142 143 function MetaColumnNames($table) 144 { 145 $table = $this->Quote(strtoupper($table)); 146 147 return $this->GetCol("SELECT columnname FROM COLUMNS WHERE tablename=$table ORDER BY pos"); 148 } 149 150 // unlike it seems, this depends on the db-session and works in a multiuser environment 151 function _insertid($table,$column) 152 { 153 return empty($table) ? False : $this->GetOne("SELECT $table.CURRVAL FROM DUAL"); 154 } 155 38 156 /* 39 157 SelectLimit implementation problems:
Note: See TracChangeset
for help on using the changeset viewer.