curMode = SQL_CUR_USE_ODBC; $db->Connect($dsn, $userid, $pwd); */ if (!defined('_ADODB_ODBC_LAYER')) { include(ADODB_DIR."/drivers/adodb-odbc.inc.php"); } if (!defined('ADODB_DB2')){ define('ADODB_DB2',1); class ADODB_DB2 extends ADODB_odbc { var $databaseType = "db2"; var $concat_operator = 'CONCAT'; var $sysDate = 'CURRENT DATE'; var $sysTimeStamp = 'CURRENT TIMESTAMP'; var $ansiOuter = true; //var $curmode = SQL_CUR_USE_ODBC; function ADODB_DB2() { $this->ADODB_odbc(); } function RowLock($tables,$where) { if ($this->_autocommit) $this->BeginTrans(); return $this->GetOne("select 1 as ignore from $tables where $where for update"); } // Format date column in sql string given an input format that understands Y M D function SQLDate($fmt, $col=false) { // use right() and replace() ? if (!$col) $col = $this->sysDate; $s = ''; $len = strlen($fmt); for ($i=0; $i < $len; $i++) { if ($s) $s .= '+'; $ch = $fmt[$i]; switch($ch) { case 'Y': case 'y': $s .= "char(year($col))"; break; case 'M': case 'm': $s .= "right(digits(month($col)),2)"; break; case 'D': case 'd': $s .= "right(digits(day($col)),2)"; break; default: $s .= $this->qstr($ch); } } return $s; } function &SelectLimit($sql,$nrows=-1,$offset=-1,$arg3=false) { if ($offset <= 0) { // could also use " OPTIMIZE FOR $nrows ROWS " $sql .= " FETCH FIRST $nrows ROWS ONLY "; return $this->Execute($sql,false,$arg3); } else { $nrows += $offset; $sql .= " FETCH FIRST $nrows ROWS ONLY "; return ADOConnection::SelectLimit($sql,-1,$offset,$arg3); } } }; class ADORecordSet_db2 extends ADORecordSet_odbc { var $databaseType = "db2"; function ADORecordSet_db2($id,$mode=false) { $this->ADORecordSet_odbc($id,$mode); } function MetaType($t,$len=-1,$fieldobj=false) { switch (strtoupper($t)) { case 'VARCHAR': case 'CHAR': case 'CHARACTER': if ($len <= $this->blobSize) return 'C'; case 'LONGCHAR': case 'TEXT': case 'CLOB': case 'DBCLOB': // double-byte return 'X'; case 'BLOB': case 'GRAPHIC': case 'VARGRAPHIC': return 'B'; case 'DATE': return 'D'; case 'TIME': case 'TIMESTAMP': return 'T'; //case 'BOOLEAN': //case 'BIT': // return 'L'; //case 'COUNTER': // return 'R'; case 'INT': case 'INTEGER': case 'BIGINT': case 'SMALLINT': return 'I'; default: return 'N'; } } } } //define ?>