function _connect($HostOrInterface, $UserOrDSN = '', $argPassword = '', $argDatabase = '') { $this->_connectionID = @odbtp_connect($HostOrInterface, $UserOrDSN, $argPassword, $argDatabase); if ($this->_connectionID === false) { $this->_errorMsg = $this->ErrorMsg(); return false; } $this->odbc_driver = @odbtp_get_attr(ODB_ATTR_DRIVER, $this->_connectionID); // Set driver specific attributes switch ($this->odbc_driver) { case ODB_DRIVER_MSSQL: $this->fmtDate = "'Y-m-d'"; $this->fmtTimeStamp = "'Y-m-d h:i:sA'"; $this->sysDate = 'convert(datetime,convert(char,GetDate(),102),102)'; $this->sysTimeStamp = 'GetDate()'; $this->ansiOuter = true; $this->leftOuter = '*='; $this->rightOuter = '=*'; $this->hasTop = 'top'; $this->hasInsertID = true; $this->hasTransactions = true; $this->_bindInputArray = true; $this->_canSelectDb = true; $this->substr = "substring"; $this->length = 'len'; $this->upperCase = 'upper'; $this->identitySQL = 'select @@IDENTITY'; $this->metaDatabasesSQL = "select name from master..sysdatabases where name <> 'master'"; break; case ODB_DRIVER_JET: $this->fmtDate = "#Y-m-d#"; $this->fmtTimeStamp = "#Y-m-d h:i:sA#"; $this->sysDate = "FORMAT(NOW,'yyyy-mm-dd')"; $this->sysTimeStamp = 'NOW'; $this->hasTop = 'top'; $this->hasTransactions = false; $this->_canPrepareSP = true; // For MS Access only. // Can't rebind ODB_CHAR to ODB_WCHAR if row cache enabled. if ($this->_useUnicodeSQL) { odbtp_use_row_cache($this->_connectionID, FALSE, 0); } break; case ODB_DRIVER_FOXPRO: $this->fmtDate = "{^Y-m-d}"; $this->fmtTimeStamp = "{^Y-m-d, h:i:sA}"; $this->sysDate = 'date()'; $this->sysTimeStamp = 'datetime()'; $this->ansiOuter = true; $this->hasTop = 'top'; $this->hasTransactions = false; $this->replaceQuote = "'+chr(39)+'"; $this->true = '.T.'; $this->false = '.F.'; $this->upperCase = 'upper'; break; case ODB_DRIVER_ORACLE: $this->fmtDate = "'Y-m-d 00:00:00'"; $this->fmtTimeStamp = "'Y-m-d h:i:sA'"; $this->sysDate = 'TRUNC(SYSDATE)'; $this->sysTimeStamp = 'SYSDATE'; $this->hasTransactions = true; $this->_bindInputArray = true; $this->concat_operator = '||'; break; case ODB_DRIVER_SYBASE: $this->fmtDate = "'Y-m-d'"; $this->fmtTimeStamp = "'Y-m-d H:i:s'"; $this->sysDate = 'GetDate()'; $this->sysTimeStamp = 'GetDate()'; $this->leftOuter = '*='; $this->rightOuter = '=*'; $this->hasInsertID = true; $this->hasTransactions = true; $this->upperCase = 'upper'; $this->identitySQL = 'select @@IDENTITY'; break; default: if (@odbtp_get_attr(ODB_ATTR_TXNCAPABLE, $this->_connectionID)) { $this->hasTransactions = true; } else { $this->hasTransactions = false; } } @odbtp_set_attr(ODB_ATTR_FULLCOLINFO, TRUE, $this->_connectionID); if ($this->_useUnicodeSQL) { @odbtp_set_attr(ODB_ATTR_UNICODESQL, TRUE, $this->_connectionID); } return true; }
function _connect($HostOrInterface, $UserOrDSN = '', $argPassword = '', $argDatabase = '') { $this->_connectionID = @odbtp_connect($HostOrInterface, $UserOrDSN, $argPassword, $argDatabase); if ($this->_connectionID === false) { $this->_errorMsg = $this->ErrorMsg(); return false; } if ($this->_dontPoolDBC) { if (function_exists('odbtp_dont_pool_dbc')) { @odbtp_dont_pool_dbc($this->_connectionID); } } else { $this->_dontPoolDBC = true; } $this->odbc_driver = @odbtp_get_attr(ODB_ATTR_DRIVER, $this->_connectionID); $dbms = strtolower(@odbtp_get_attr(ODB_ATTR_DBMSNAME, $this->_connectionID)); $this->odbc_name = $dbms; // Account for inconsistent DBMS names if ($this->odbc_driver == ODB_DRIVER_ORACLE) { $dbms = 'oracle'; } else { if ($this->odbc_driver == ODB_DRIVER_SYBASE) { $dbms = 'sybase'; } } // Set DBMS specific attributes switch ($dbms) { case 'microsoft sql server': $this->databaseType = 'odbtp_mssql'; $this->fmtDate = "'Y-m-d'"; $this->fmtTimeStamp = "'Y-m-d h:i:sA'"; $this->sysDate = 'convert(datetime,convert(char,GetDate(),102),102)'; $this->sysTimeStamp = 'GetDate()'; $this->ansiOuter = true; $this->leftOuter = '*='; $this->rightOuter = '=*'; $this->hasTop = 'top'; $this->hasInsertID = true; $this->hasTransactions = true; $this->_bindInputArray = true; $this->_canSelectDb = true; $this->substr = "substring"; $this->length = 'len'; $this->identitySQL = 'select @@IDENTITY'; $this->metaDatabasesSQL = "select name from master..sysdatabases where name <> 'master'"; $this->_canPrepareSP = true; break; case 'access': $this->databaseType = 'odbtp_access'; $this->fmtDate = "#Y-m-d#"; $this->fmtTimeStamp = "#Y-m-d h:i:sA#"; $this->sysDate = "FORMAT(NOW,'yyyy-mm-dd')"; $this->sysTimeStamp = 'NOW'; $this->hasTop = 'top'; $this->hasTransactions = false; $this->_canPrepareSP = true; // For MS Access only. break; case 'visual foxpro': $this->databaseType = 'odbtp_vfp'; $this->fmtDate = "{^Y-m-d}"; $this->fmtTimeStamp = "{^Y-m-d, h:i:sA}"; $this->sysDate = 'date()'; $this->sysTimeStamp = 'datetime()'; $this->ansiOuter = true; $this->hasTop = 'top'; $this->hasTransactions = false; $this->replaceQuote = "'+chr(39)+'"; $this->true = '.T.'; $this->false = '.F.'; break; case 'oracle': $this->databaseType = 'odbtp_oci8'; $this->fmtDate = "'Y-m-d 00:00:00'"; $this->fmtTimeStamp = "'Y-m-d h:i:sA'"; $this->sysDate = 'TRUNC(SYSDATE)'; $this->sysTimeStamp = 'SYSDATE'; $this->hasTransactions = true; $this->_bindInputArray = true; $this->concat_operator = '||'; break; case 'sybase': $this->databaseType = 'odbtp_sybase'; $this->fmtDate = "'Y-m-d'"; $this->fmtTimeStamp = "'Y-m-d H:i:s'"; $this->sysDate = 'GetDate()'; $this->sysTimeStamp = 'GetDate()'; $this->leftOuter = '*='; $this->rightOuter = '=*'; $this->hasInsertID = true; $this->hasTransactions = true; $this->identitySQL = 'select @@IDENTITY'; break; default: $this->databaseType = 'odbtp'; if (@odbtp_get_attr(ODB_ATTR_TXNCAPABLE, $this->_connectionID)) { $this->hasTransactions = true; } else { $this->hasTransactions = false; } } @odbtp_set_attr(ODB_ATTR_FULLCOLINFO, TRUE, $this->_connectionID); if ($this->_useUnicodeSQL) { @odbtp_set_attr(ODB_ATTR_UNICODESQL, TRUE, $this->_connectionID); } return true; }
function _connect($argHost, $argUsername = '', $argPassword = '', $argDSN = '', $persist = false) { if ($argUsername) { $argDSN .= ";uid={$argUsername}"; } if ($argPassword) { $argDSN .= ";pwd={$argPassword}"; } if ($persist) { $this->_connectionID = @odbtp_rconnect($argHost, $argDSN); } else { $this->_connectionID = @odbtp_connect($argHost, $argDSN); } if ($this->_connectionID === false) { $this->_errorMsg = $this->ErrorMsg(); return false; } $this->odbc_driver = @odbtp_get_attr(ODB_ATTR_DRIVER, $this->_connectionID); //$this->oic_level = @odbtp_get_attr(ODB_ATTR_OICLEVEL, $this->_connectionID); $tc = @odbtp_get_attr('ODB_ATTR_TXNCAPABLE', $this->_connectionID); if ($tc == 0) { $this->hasTransactions = false; } else { $this->hasTransactions = true; } return true; }