16 if (!defined(
'ADODB_DIR'))
die();
18 if (!defined(
'_ADODB_ODBC_LAYER')) {
19 include(ADODB_DIR.
"/drivers/adodb-odbc.inc.php");
21 if (!defined(
'ADODB_SAPDB')){
22 define(
'ADODB_SAPDB',1);
25 var $databaseType =
"sapdb";
26 var $concat_operator =
'||';
27 var $sysDate =
'DATE';
28 var $sysTimeStamp =
'TIMESTAMP';
29 var $fmtDate =
"'Y-m-d'";
30 var $fmtTimeStamp =
"'Y-m-d H:i:s'";
31 var $hasInsertId =
true;
32 var $_bindInputArray =
true;
34 function ADODB_SAPDB()
43 if (!$info[
'version'] && preg_match(
'/([0-9.]+)/',$info[
'description'],$matches)) {
44 $info[
'version'] = $matches[1];
51 $table = $this->Quote(strtoupper($table));
53 return $this->GetCol(
"SELECT columnname FROM COLUMNS WHERE tablename=$table AND mode='KEY' ORDER BY pos");
56 function MetaIndexes ($table, $primary = FALSE, $owner =
false)
58 $table = $this->Quote(strtoupper($table));
60 $sql =
"SELECT INDEXNAME,TYPE,COLUMNNAME FROM INDEXCOLUMNS ".
61 " WHERE TABLENAME=$table".
62 " ORDER BY INDEXNAME,COLUMNNO";
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);
73 $this->SetFetchMode($savem);
75 $ADODB_FETCH_MODE = $save;
77 if (!is_object(
$rs)) {
82 while ($row =
$rs->FetchRow()) {
83 $indexes[$row[0]][
'unique'] = $row[1] ==
'UNIQUE';
84 $indexes[$row[0]][
'columns'][] = $row[2];
87 $indexes[
'SYSPRIMARYKEYINDEX'] = array(
89 'columns' => $this->GetCol(
"SELECT columnname FROM COLUMNS WHERE tablename=$table AND mode='KEY' ORDER BY pos"),
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);
103 $table = $this->Quote(strtoupper($table));
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)
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;
120 $fld->default_value = $column[6];
125 $fld->default_value = $column[6];
128 $fld->default_value = trim($column[6]);
133 $retarr[$fld->name] = $fld;
136 $this->SetFetchMode($savem);
138 $ADODB_FETCH_MODE = $save;
143 function MetaColumnNames($table)
145 $table = $this->Quote(strtoupper($table));
147 return $this->GetCol(
"SELECT columnname FROM COLUMNS WHERE tablename=$table ORDER BY pos");
151 function _insertid($table,$column)
153 return empty($table) ? False : $this->GetOne(
"SELECT $table.CURRVAL FROM DUAL");
175 var $databaseType =
"sapdb";
177 function ADORecordSet_sapdb($id,$mode=
false)
if(isset($_REQUEST['nrows'])) else $rs
MetaColumns($table, $normalize=true)
MetaPrimaryKeys($table, $owner=false)