diff options
author | wei <> | 2006-12-16 03:56:03 +0000 |
---|---|---|
committer | wei <> | 2006-12-16 03:56:03 +0000 |
commit | ddc0de38f64e5834ce04f0407a8416172b596655 (patch) | |
tree | a94c75b6e7a4f443f748124b84e30d02826bb23a /framework/3rdParty/adodb/drivers | |
parent | c8689010d28a0fe2a734131a2964d7df394cdf6c (diff) |
removed adodb and framework/DataAccess
Diffstat (limited to 'framework/3rdParty/adodb/drivers')
23 files changed, 0 insertions, 10112 deletions
diff --git a/framework/3rdParty/adodb/drivers/adodb-ado5.inc.php b/framework/3rdParty/adodb/drivers/adodb-ado5.inc.php deleted file mode 100644 index 03c09011..00000000 --- a/framework/3rdParty/adodb/drivers/adodb-ado5.inc.php +++ /dev/null @@ -1,646 +0,0 @@ -<?php -/* -V4.81 3 May 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved. - Released under both BSD license and Lesser GPL library license. - Whenever there is any discrepancy between the two licenses, - the BSD license will take precedence. -Set tabs to 4 for best viewing. - - Latest version is available at http://adodb.sourceforge.net - - Microsoft ADO data driver. Requires ADO. Works only on MS Windows. PHP5 compat version. -*/ - -// security - hide paths -if (!defined('ADODB_DIR')) die(); - -define("_ADODB_ADO_LAYER", 1 ); -/*-------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------*/ - - -class ADODB_ado extends ADOConnection { - var $databaseType = "ado"; - var $_bindInputArray = false; - var $fmtDate = "'Y-m-d'"; - var $fmtTimeStamp = "'Y-m-d, h:i:sA'"; - var $replaceQuote = "''"; // string to use to replace quotes - var $dataProvider = "ado"; - var $hasAffectedRows = true; - var $adoParameterType = 201; // 201 = long varchar, 203=long wide varchar, 205 = long varbinary - var $_affectedRows = false; - var $_thisTransactions; - var $_cursor_type = 3; // 3=adOpenStatic,0=adOpenForwardOnly,1=adOpenKeyset,2=adOpenDynamic - var $_cursor_location = 3; // 2=adUseServer, 3 = adUseClient; - var $_lock_type = -1; - var $_execute_option = -1; - var $poorAffectedRows = true; - var $charPage; - - function ADODB_ado() - { - $this->_affectedRows = new VARIANT; - } - - function ServerInfo() - { - if (!empty($this->_connectionID)) $desc = $this->_connectionID->provider; - return array('description' => $desc, 'version' => ''); - } - - function _affectedrows() - { - if (PHP_VERSION >= 5) return $this->_affectedRows; - - return $this->_affectedRows->value; - } - - // you can also pass a connection string like this: - // - // $DB->Connect('USER ID=sa;PASSWORD=pwd;SERVER=mangrove;DATABASE=ai',false,false,'SQLOLEDB'); - function _connect($argHostname, $argUsername, $argPassword, $argProvider= 'MSDASQL') - { - try { - $u = 'UID'; - $p = 'PWD'; - - if (!empty($this->charPage)) - $dbc = new COM('ADODB.Connection',null,$this->charPage); - else - $dbc = new COM('ADODB.Connection'); - - if (! $dbc) return false; - - /* special support if provider is mssql or access */ - if ($argProvider=='mssql') { - $u = 'User Id'; //User parameter name for OLEDB - $p = 'Password'; - $argProvider = "SQLOLEDB"; // SQL Server Provider - - // not yet - //if ($argDatabasename) $argHostname .= ";Initial Catalog=$argDatabasename"; - - //use trusted conection for SQL if username not specified - if (!$argUsername) $argHostname .= ";Trusted_Connection=Yes"; - } else if ($argProvider=='access') - $argProvider = "Microsoft.Jet.OLEDB.4.0"; // Microsoft Jet Provider - - if ($argProvider) $dbc->Provider = $argProvider; - - if ($argUsername) $argHostname .= ";$u=$argUsername"; - if ($argPassword)$argHostname .= ";$p=$argPassword"; - - if ($this->debug) ADOConnection::outp( "Host=".$argHostname."<BR>\n version=$dbc->version"); - // @ added below for php 4.0.1 and earlier - @$dbc->Open((string) $argHostname); - - $this->_connectionID = $dbc; - - $dbc->CursorLocation = $this->_cursor_location; - return $dbc->State > 0; - } catch (exception $e) { - } - - return false; - } - - // returns true or false - function _pconnect($argHostname, $argUsername, $argPassword, $argProvider='MSDASQL') - { - return $this->_connect($argHostname,$argUsername,$argPassword,$argProvider); - } - -/* - adSchemaCatalogs = 1, - adSchemaCharacterSets = 2, - adSchemaCollations = 3, - adSchemaColumns = 4, - adSchemaCheckConstraints = 5, - adSchemaConstraintColumnUsage = 6, - adSchemaConstraintTableUsage = 7, - adSchemaKeyColumnUsage = 8, - adSchemaReferentialContraints = 9, - adSchemaTableConstraints = 10, - adSchemaColumnsDomainUsage = 11, - adSchemaIndexes = 12, - adSchemaColumnPrivileges = 13, - adSchemaTablePrivileges = 14, - adSchemaUsagePrivileges = 15, - adSchemaProcedures = 16, - adSchemaSchemata = 17, - adSchemaSQLLanguages = 18, - adSchemaStatistics = 19, - adSchemaTables = 20, - adSchemaTranslations = 21, - adSchemaProviderTypes = 22, - adSchemaViews = 23, - adSchemaViewColumnUsage = 24, - adSchemaViewTableUsage = 25, - adSchemaProcedureParameters = 26, - adSchemaForeignKeys = 27, - adSchemaPrimaryKeys = 28, - adSchemaProcedureColumns = 29, - adSchemaDBInfoKeywords = 30, - adSchemaDBInfoLiterals = 31, - adSchemaCubes = 32, - adSchemaDimensions = 33, - adSchemaHierarchies = 34, - adSchemaLevels = 35, - adSchemaMeasures = 36, - adSchemaProperties = 37, - adSchemaMembers = 38 - -*/ - - function &MetaTables() - { - $arr= array(); - $dbc = $this->_connectionID; - - $adors=@$dbc->OpenSchema(20);//tables - if ($adors){ - $f = $adors->Fields(2);//table/view name - $t = $adors->Fields(3);//table type - while (!$adors->EOF){ - $tt=substr($t->value,0,6); - if ($tt!='SYSTEM' && $tt !='ACCESS') - $arr[]=$f->value; - //print $f->value . ' ' . $t->value.'<br>'; - $adors->MoveNext(); - } - $adors->Close(); - } - - return $arr; - } - - function &MetaColumns($table) - { - $table = strtoupper($table); - $arr= array(); - $dbc = $this->_connectionID; - - $adors=@$dbc->OpenSchema(4);//tables - - if ($adors){ - $t = $adors->Fields(2);//table/view name - while (!$adors->EOF){ - - - if (strtoupper($t->Value) == $table) { - - $fld = new ADOFieldObject(); - $c = $adors->Fields(3); - $fld->name = $c->Value; - $fld->type = 'CHAR'; // cannot discover type in ADO! - $fld->max_length = -1; - $arr[strtoupper($fld->name)]=$fld; - } - - $adors->MoveNext(); - } - $adors->Close(); - } - - return $arr; - } - - - - - /* returns queryID or false */ - function &_query($sql,$inputarr=false) - { - try { // In PHP5, all COM errors are exceptions, so to maintain old behaviour... - - $dbc = $this->_connectionID; - - // return rs - - $false = false; - - if ($inputarr) { - - if (!empty($this->charPage)) - $oCmd = new COM('ADODB.Command',null,$this->charPage); - else - $oCmd = new COM('ADODB.Command'); - $oCmd->ActiveConnection = $dbc; - $oCmd->CommandText = $sql; - $oCmd->CommandType = 1; - - foreach($inputarr as $val) { - // name, type, direction 1 = input, len, - $this->adoParameterType = 130; - $p = $oCmd->CreateParameter('name',$this->adoParameterType,1,strlen($val),$val); - //print $p->Type.' '.$p->value; - $oCmd->Parameters->Append($p); - } - $p = false; - $rs = $oCmd->Execute(); - $e = $dbc->Errors; - if ($dbc->Errors->Count > 0) return $false; - return $rs; - } - - $rs = @$dbc->Execute($sql,$this->_affectedRows, $this->_execute_option); - - if ($dbc->Errors->Count > 0) return $false; - if (! $rs) return $false; - - if ($rs->State == 0) { - $true = true; - return $true; // 0 = adStateClosed means no records returned - } return $rs; - - } catch (exception $e) { - - } - return $false; - } - - - function BeginTrans() - { - if ($this->transOff) return true; - - if (isset($this->_thisTransactions)) - if (!$this->_thisTransactions) return false; - else { - $o = $this->_connectionID->Properties("Transaction DDL"); - $this->_thisTransactions = $o ? true : false; - if (!$o) return false; - } - @$this->_connectionID->BeginTrans(); - $this->transCnt += 1; - return true; - } - function CommitTrans($ok=true) - { - if (!$ok) return $this->RollbackTrans(); - if ($this->transOff) return true; - - @$this->_connectionID->CommitTrans(); - if ($this->transCnt) @$this->transCnt -= 1; - return true; - } - function RollbackTrans() { - if ($this->transOff) return true; - @$this->_connectionID->RollbackTrans(); - if ($this->transCnt) @$this->transCnt -= 1; - return true; - } - - /* Returns: the last error message from previous database operation */ - - function ErrorMsg() - { - if (!$this->_connectionID) return "No connection established"; - $errc = $this->_connectionID->Errors; - if (!$errc) return "No Errors object found"; - if ($errc->Count == 0) return ''; - $err = $errc->Item($errc->Count-1); - return $err->Description; - } - - function ErrorNo() - { - $errc = $this->_connectionID->Errors; - if ($errc->Count == 0) return 0; - $err = $errc->Item($errc->Count-1); - return $err->NativeError; - } - - // returns true or false - function _close() - { - if ($this->_connectionID) $this->_connectionID->Close(); - $this->_connectionID = false; - return true; - } - - -} - -/*-------------------------------------------------------------------------------------- - Class Name: Recordset ---------------------------------------------------------------------------------------*/ - -class ADORecordSet_ado extends ADORecordSet { - - var $bind = false; - var $databaseType = "ado"; - var $dataProvider = "ado"; - var $_tarr = false; // caches the types - var $_flds; // and field objects - var $canSeek = true; - var $hideErrors = true; - - function ADORecordSet_ado($id,$mode=false) - { - if ($mode === false) { - global $ADODB_FETCH_MODE; - $mode = $ADODB_FETCH_MODE; - } - $this->fetchMode = $mode; - return $this->ADORecordSet($id,$mode); - } - - - // returns the field object - function &FetchField($fieldOffset = -1) { - $off=$fieldOffset+1; // offsets begin at 1 - - $o= new ADOFieldObject(); - $rs = $this->_queryID; - $f = $rs->Fields($fieldOffset); - $o->name = $f->Name; - $t = $f->Type; - $o->type = $this->MetaType($t); - $o->max_length = $f->DefinedSize; - $o->ado_type = $t; - - - //print "off=$off name=$o->name type=$o->type len=$o->max_length<br>"; - return $o; - } - - /* Use associative array to get fields array */ - function Fields($colname) - { - if ($this->fetchMode & ADODB_FETCH_ASSOC) return $this->fields[$colname]; - if (!$this->bind) { - $this->bind = array(); - for ($i=0; $i < $this->_numOfFields; $i++) { - $o = $this->FetchField($i); - $this->bind[strtoupper($o->name)] = $i; - } - } - - return $this->fields[$this->bind[strtoupper($colname)]]; - } - - - function _initrs() - { - $rs = $this->_queryID; - $this->_numOfRows = $rs->RecordCount; - - $f = $rs->Fields; - $this->_numOfFields = $f->Count; - } - - - // should only be used to move forward as we normally use forward-only cursors - function _seek($row) - { - $rs = $this->_queryID; - // absoluteposition doesn't work -- my maths is wrong ? - // $rs->AbsolutePosition->$row-2; - // return true; - if ($this->_currentRow > $row) return false; - @$rs->Move((integer)$row - $this->_currentRow-1); //adBookmarkFirst - return true; - } - -/* - OLEDB types - - enum DBTYPEENUM - { DBTYPE_EMPTY = 0, - DBTYPE_NULL = 1, - DBTYPE_I2 = 2, - DBTYPE_I4 = 3, - DBTYPE_R4 = 4, - DBTYPE_R8 = 5, - DBTYPE_CY = 6, - DBTYPE_DATE = 7, - DBTYPE_BSTR = 8, - DBTYPE_IDISPATCH = 9, - DBTYPE_ERROR = 10, - DBTYPE_BOOL = 11, - DBTYPE_VARIANT = 12, - DBTYPE_IUNKNOWN = 13, - DBTYPE_DECIMAL = 14, - DBTYPE_UI1 = 17, - DBTYPE_ARRAY = 0x2000, - DBTYPE_BYREF = 0x4000, - DBTYPE_I1 = 16, - DBTYPE_UI2 = 18, - DBTYPE_UI4 = 19, - DBTYPE_I8 = 20, - DBTYPE_UI8 = 21, - DBTYPE_GUID = 72, - DBTYPE_VECTOR = 0x1000, - DBTYPE_RESERVED = 0x8000, - DBTYPE_BYTES = 128, - DBTYPE_STR = 129, - DBTYPE_WSTR = 130, - DBTYPE_NUMERIC = 131, - DBTYPE_UDT = 132, - DBTYPE_DBDATE = 133, - DBTYPE_DBTIME = 134, - DBTYPE_DBTIMESTAMP = 135 - - ADO Types - - adEmpty = 0, - adTinyInt = 16, - adSmallInt = 2, - adInteger = 3, - adBigInt = 20, - adUnsignedTinyInt = 17, - adUnsignedSmallInt = 18, - adUnsignedInt = 19, - adUnsignedBigInt = 21, - adSingle = 4, - adDouble = 5, - adCurrency = 6, - adDecimal = 14, - adNumeric = 131, - adBoolean = 11, - adError = 10, - adUserDefined = 132, - adVariant = 12, - adIDispatch = 9, - adIUnknown = 13, - adGUID = 72, - adDate = 7, - adDBDate = 133, - adDBTime = 134, - adDBTimeStamp = 135, - adBSTR = 8, - adChar = 129, - adVarChar = 200, - adLongVarChar = 201, - adWChar = 130, - adVarWChar = 202, - adLongVarWChar = 203, - adBinary = 128, - adVarBinary = 204, - adLongVarBinary = 205, - adChapter = 136, - adFileTime = 64, - adDBFileTime = 137, - adPropVariant = 138, - adVarNumeric = 139 -*/ - function MetaType($t,$len=-1,$fieldobj=false) - { - if (is_object($t)) { - $fieldobj = $t; - $t = $fieldobj->type; - $len = $fieldobj->max_length; - } - - if (!is_numeric($t)) return $t; - - switch ($t) { - case 0: - case 12: // variant - case 8: // bstr - case 129: //char - case 130: //wc - case 200: // varc - case 202:// varWC - case 128: // bin - case 204: // varBin - case 72: // guid - if ($len <= $this->blobSize) return 'C'; - - case 201: - case 203: - return 'X'; - case 128: - case 204: - case 205: - return 'B'; - case 7: - case 133: return 'D'; - - case 134: - case 135: return 'T'; - - case 11: return 'L'; - - case 16:// adTinyInt = 16, - case 2://adSmallInt = 2, - case 3://adInteger = 3, - case 4://adBigInt = 20, - case 17://adUnsignedTinyInt = 17, - case 18://adUnsignedSmallInt = 18, - case 19://adUnsignedInt = 19, - case 20://adUnsignedBigInt = 21, - return 'I'; - default: return 'N'; - } - } - - // time stamp not supported yet - function _fetch() - { - $rs = $this->_queryID; - if (!$rs or $rs->EOF) { - $this->fields = false; - return false; - } - $this->fields = array(); - - if (!$this->_tarr) { - $tarr = array(); - $flds = array(); - for ($i=0,$max = $this->_numOfFields; $i < $max; $i++) { - $f = $rs->Fields($i); - $flds[] = $f; - $tarr[] = $f->Type; - } - // bind types and flds only once - $this->_tarr = $tarr; - $this->_flds = $flds; - } - $t = reset($this->_tarr); - $f = reset($this->_flds); - - if ($this->hideErrors) $olde = error_reporting(E_ERROR|E_CORE_ERROR);// sometimes $f->value be null - for ($i=0,$max = $this->_numOfFields; $i < $max; $i++) { - //echo "<p>",$t,' ';var_dump($f->value); echo '</p>'; - switch($t) { - case 135: // timestamp - if (!strlen((string)$f->value)) $this->fields[] = false; - else { - if (!is_numeric($f->value)) # $val = variant_date_to_timestamp($f->value); - // VT_DATE stores dates as (float) fractional days since 1899/12/30 00:00:00 - $val= (float) variant_cast($f->value,VT_R8)*3600*24-2209161600; - else - $val = $f->value; - $this->fields[] = adodb_date('Y-m-d H:i:s',$val); - } - break; - case 133:// A date value (yyyymmdd) - if ($val = $f->value) { - $this->fields[] = substr($val,0,4).'-'.substr($val,4,2).'-'.substr($val,6,2); - } else - $this->fields[] = false; - break; - case 7: // adDate - if (!strlen((string)$f->value)) $this->fields[] = false; - else { - if (!is_numeric($f->value)) $val = variant_date_to_timestamp($f->value); - else $val = $f->value; - - if (($val % 86400) == 0) $this->fields[] = adodb_date('Y-m-d',$val); - else $this->fields[] = adodb_date('Y-m-d H:i:s',$val); - } - break; - case 1: // null - $this->fields[] = false; - break; - case 6: // currency is not supported properly; - ADOConnection::outp( '<b>'.$f->Name.': currency type not supported by PHP</b>'); - $this->fields[] = (float) $f->value; - break; - default: - $this->fields[] = $f->value; - break; - } - //print " $f->value $t, "; - $f = next($this->_flds); - $t = next($this->_tarr); - } // for - if ($this->hideErrors) error_reporting($olde); - @$rs->MoveNext(); // @ needed for some versions of PHP! - - if ($this->fetchMode & ADODB_FETCH_ASSOC) { - $this->fields = &$this->GetRowAssoc(ADODB_ASSOC_CASE); - } - return true; - } - - function NextRecordSet() - { - $rs = $this->_queryID; - $this->_queryID = $rs->NextRecordSet(); - //$this->_queryID = $this->_QueryId->NextRecordSet(); - if ($this->_queryID == null) return false; - - $this->_currentRow = -1; - $this->_currentPage = -1; - $this->bind = false; - $this->fields = false; - $this->_flds = false; - $this->_tarr = false; - - $this->_inited = false; - $this->Init(); - return true; - } - - function _close() { - $this->_flds = false; - @$this->_queryID->Close();// by Pete Dishman (peterd@telephonetics.co.uk) - $this->_queryID = false; - } - -} - -?>
\ No newline at end of file diff --git a/framework/3rdParty/adodb/drivers/adodb-ado_mssql.inc.php b/framework/3rdParty/adodb/drivers/adodb-ado_mssql.inc.php deleted file mode 100644 index 3a5e6914..00000000 --- a/framework/3rdParty/adodb/drivers/adodb-ado_mssql.inc.php +++ /dev/null @@ -1,98 +0,0 @@ -<?php -/* -V4.81 3 May 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved. - Released under both BSD license and Lesser GPL library license. - Whenever there is any discrepancy between the two licenses, - the BSD license will take precedence. -Set tabs to 4 for best viewing. - - Latest version is available at http://adodb.sourceforge.net - - Microsoft SQL Server ADO data driver. Requires ADO and MSSQL client. - Works only on MS Windows. - - It is normally better to use the mssql driver directly because it is much faster. - This file is only a technology demonstration and for test purposes. -*/ - -// security - hide paths -if (!defined('ADODB_DIR')) die(); - -if (!defined('_ADODB_ADO_LAYER')) { - if (PHP_VERSION >= 5) include(ADODB_DIR."/drivers/adodb-ado5.inc.php"); - else include(ADODB_DIR."/drivers/adodb-ado.inc.php"); -} - - -class ADODB_ado_mssql extends ADODB_ado { - var $databaseType = 'ado_mssql'; - var $hasTop = 'top'; - var $hasInsertID = true; - var $sysDate = 'convert(datetime,convert(char,GetDate(),102),102)'; - var $sysTimeStamp = 'GetDate()'; - var $leftOuter = '*='; - var $rightOuter = '=*'; - var $ansiOuter = true; // for mssql7 or later - var $substr = "substring"; - var $length = 'len'; - - //var $_inTransaction = 1; // always open recordsets, so no transaction problems. - - function ADODB_ado_mssql() - { - $this->ADODB_ado(); - } - - function _insertid() - { - return $this->GetOne('select @@identity'); - } - - function _affectedrows() - { - return $this->GetOne('select @@rowcount'); - } - - function MetaColumns($table) - { - $table = strtoupper($table); - $arr= array(); - $dbc = $this->_connectionID; - - $osoptions = array(); - $osoptions[0] = null; - $osoptions[1] = null; - $osoptions[2] = $table; - $osoptions[3] = null; - - $adors=@$dbc->OpenSchema(4, $osoptions);//tables - - if ($adors){ - while (!$adors->EOF){ - $fld = new ADOFieldObject(); - $c = $adors->Fields(3); - $fld->name = $c->Value; - $fld->type = 'CHAR'; // cannot discover type in ADO! - $fld->max_length = -1; - $arr[strtoupper($fld->name)]=$fld; - - $adors->MoveNext(); - } - $adors->Close(); - } - $false = false; - return empty($arr) ? $false : $arr; - } - - } // end class - - class ADORecordSet_ado_mssql extends ADORecordSet_ado { - - var $databaseType = 'ado_mssql'; - - function ADORecordSet_ado_mssql($id,$mode=false) - { - return $this->ADORecordSet_ado($id,$mode); - } -} -?>
\ No newline at end of file diff --git a/framework/3rdParty/adodb/drivers/adodb-ldap.inc.php b/framework/3rdParty/adodb/drivers/adodb-ldap.inc.php deleted file mode 100644 index 38b0b576..00000000 --- a/framework/3rdParty/adodb/drivers/adodb-ldap.inc.php +++ /dev/null @@ -1,406 +0,0 @@ -<?php -/* - V4.81 3 May 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved. - Released under both BSD license and Lesser GPL library license. - Whenever there is any discrepancy between the two licenses, - the BSD license will take precedence. - Set tabs to 8. - - Revision 1: (02/25/2005) Updated codebase to include the _inject_bind_options function. This allows - users to access the options in the ldap_set_option function appropriately. Most importantly - LDAP Version 3 is now supported. See the examples for more information. Also fixed some minor - bugs that surfaced when PHP error levels were set high. - - Joshua Eldridge (joshuae74#hotmail.com) -*/ - -// security - hide paths -if (!defined('ADODB_DIR')) die(); - -if (!defined('LDAP_ASSOC')) { - define('LDAP_ASSOC',ADODB_FETCH_ASSOC); - define('LDAP_NUM',ADODB_FETCH_NUM); - define('LDAP_BOTH',ADODB_FETCH_BOTH); -} - -class ADODB_ldap extends ADOConnection { - var $databaseType = 'ldap'; - var $dataProvider = 'ldap'; - - # Connection information - var $username = false; - var $password = false; - - # Used during searches - var $filter; - var $dn; - var $version; - var $port = 389; - - # Options configuration information - var $LDAP_CONNECT_OPTIONS; - - function ADODB_ldap() - { - } - - // returns true or false - - function _connect( $host, $username, $password, $ldapbase) - { - global $LDAP_CONNECT_OPTIONS; - - if ( !function_exists( 'ldap_connect' ) ) return null; - - $conn_info = array( $host,$this->port); - - if ( strstr( $host, ':' ) ) { - $conn_info = split( ':', $host ); - } - - $this->_connectionID = ldap_connect( $conn_info[0], $conn_info[1] ); - if (!$this->_connectionID) { - $e = 'Could not connect to ' . $conn_info[0]; - $this->_errorMsg = $e; - if ($this->debug) ADOConnection::outp($e); - return false; - } - if( count( $LDAP_CONNECT_OPTIONS ) > 0 ) { - $this->_inject_bind_options( $LDAP_CONNECT_OPTIONS ); - } - - if ($username) { - $bind = ldap_bind( $this->_connectionID, $username, $password ); - } else { - $username = 'anonymous'; - $bind = ldap_bind( $this->_connectionID ); - } - - if (!$bind) { - $e = 'Could not bind to ' . $conn_info[0] . " as ".$username; - $this->_errorMsg = $e; - if ($this->debug) ADOConnection::outp($e); - return false; - } - $this->_errorMsg = ''; - $this->database = $ldapbase; - return $this->_connectionID; - } - -/* - Valid Domain Values for LDAP Options: - - LDAP_OPT_DEREF (integer) - LDAP_OPT_SIZELIMIT (integer) - LDAP_OPT_TIMELIMIT (integer) - LDAP_OPT_PROTOCOL_VERSION (integer) - LDAP_OPT_ERROR_NUMBER (integer) - LDAP_OPT_REFERRALS (boolean) - LDAP_OPT_RESTART (boolean) - LDAP_OPT_HOST_NAME (string) - LDAP_OPT_ERROR_STRING (string) - LDAP_OPT_MATCHED_DN (string) - LDAP_OPT_SERVER_CONTROLS (array) - LDAP_OPT_CLIENT_CONTROLS (array) - - Make sure to set this BEFORE calling Connect() - - Example: - - $LDAP_CONNECT_OPTIONS = Array( - Array ( - "OPTION_NAME"=>LDAP_OPT_DEREF, - "OPTION_VALUE"=>2 - ), - Array ( - "OPTION_NAME"=>LDAP_OPT_SIZELIMIT, - "OPTION_VALUE"=>100 - ), - Array ( - "OPTION_NAME"=>LDAP_OPT_TIMELIMIT, - "OPTION_VALUE"=>30 - ), - Array ( - "OPTION_NAME"=>LDAP_OPT_PROTOCOL_VERSION, - "OPTION_VALUE"=>3 - ), - Array ( - "OPTION_NAME"=>LDAP_OPT_ERROR_NUMBER, - "OPTION_VALUE"=>13 - ), - Array ( - "OPTION_NAME"=>LDAP_OPT_REFERRALS, - "OPTION_VALUE"=>FALSE - ), - Array ( - "OPTION_NAME"=>LDAP_OPT_RESTART, - "OPTION_VALUE"=>FALSE - ) - ); -*/ - - function _inject_bind_options( $options ) { - foreach( $options as $option ) { - ldap_set_option( $this->_connectionID, $option["OPTION_NAME"], $option["OPTION_VALUE"] ) - or die( "Unable to set server option: " . $option["OPTION_NAME"] ); - } - } - - /* returns _queryID or false */ - function _query($sql,$inputarr) - { - $rs = ldap_search( $this->_connectionID, $this->database, $sql ); - $this->_errorMsg = ($rs) ? '' : 'Search error on '.$sql; - return $rs; - } - - /* closes the LDAP connection */ - function _close() - { - @ldap_close( $this->_connectionID ); - $this->_connectionID = false; - } - - function SelectDB($db) { - $this->database = $db; - return true; - } // SelectDB - - function ServerInfo() - { - if( !empty( $this->version ) ) return $this->version; - $version = array(); - /* - Determines how aliases are handled during search. - LDAP_DEREF_NEVER (0x00) - LDAP_DEREF_SEARCHING (0x01) - LDAP_DEREF_FINDING (0x02) - LDAP_DEREF_ALWAYS (0x03) - The LDAP_DEREF_SEARCHING value means aliases are dereferenced during the search but - not when locating the base object of the search. The LDAP_DEREF_FINDING value means - aliases are dereferenced when locating the base object but not during the search. - Default: LDAP_DEREF_NEVER - */ - ldap_get_option( $this->_connectionID, LDAP_OPT_DEREF, $version['LDAP_OPT_DEREF'] ) ; - switch ( $version['LDAP_OPT_DEREF'] ) { - case 0: - $version['LDAP_OPT_DEREF'] = 'LDAP_DEREF_NEVER'; - case 1: - $version['LDAP_OPT_DEREF'] = 'LDAP_DEREF_SEARCHING'; - case 2: - $version['LDAP_OPT_DEREF'] = 'LDAP_DEREF_FINDING'; - case 3: - $version['LDAP_OPT_DEREF'] = 'LDAP_DEREF_ALWAYS'; - } - - /* - A limit on the number of entries to return from a search. - LDAP_NO_LIMIT (0) means no limit. - Default: LDAP_NO_LIMIT - */ - ldap_get_option( $this->_connectionID, LDAP_OPT_SIZELIMIT, $version['LDAP_OPT_SIZELIMIT'] ); - if ( $version['LDAP_OPT_SIZELIMIT'] == 0 ) { - $version['LDAP_OPT_SIZELIMIT'] = 'LDAP_NO_LIMIT'; - } - - /* - A limit on the number of seconds to spend on a search. - LDAP_NO_LIMIT (0) means no limit. - Default: LDAP_NO_LIMIT - */ - ldap_get_option( $this->_connectionID, LDAP_OPT_TIMELIMIT, $version['LDAP_OPT_TIMELIMIT'] ); - if ( $version['LDAP_OPT_TIMELIMIT'] == 0 ) { - $version['LDAP_OPT_TIMELIMIT'] = 'LDAP_NO_LIMIT'; - } - - /* - Determines whether the LDAP library automatically follows referrals returned by LDAP servers or not. - LDAP_OPT_ON - LDAP_OPT_OFF - Default: ON - */ - ldap_get_option( $this->_connectionID, LDAP_OPT_REFERRALS, $version['LDAP_OPT_REFERRALS'] ); - if ( $version['LDAP_OPT_REFERRALS'] == 0 ) { - $version['LDAP_OPT_REFERRALS'] = 'LDAP_OPT_OFF'; - } else { - $version['LDAP_OPT_REFERRALS'] = 'LDAP_OPT_ON'; - - } - /* - Determines whether LDAP I/O operations are automatically restarted if they abort prematurely. - LDAP_OPT_ON - LDAP_OPT_OFF - Default: OFF - */ - ldap_get_option( $this->_connectionID, LDAP_OPT_RESTART, $version['LDAP_OPT_RESTART'] ); - if ( $version['LDAP_OPT_RESTART'] == 0 ) { - $version['LDAP_OPT_RESTART'] = 'LDAP_OPT_OFF'; - } else { - $version['LDAP_OPT_RESTART'] = 'LDAP_OPT_ON'; - - } - /* - This option indicates the version of the LDAP protocol used when communicating with the primary LDAP server. - LDAP_VERSION2 (2) - LDAP_VERSION3 (3) - Default: LDAP_VERSION2 (2) - */ - ldap_get_option( $this->_connectionID, LDAP_OPT_PROTOCOL_VERSION, $version['LDAP_OPT_PROTOCOL_VERSION'] ); - if ( $version['LDAP_OPT_PROTOCOL_VERSION'] == 2 ) { - $version['LDAP_OPT_PROTOCOL_VERSION'] = 'LDAP_VERSION2'; - } else { - $version['LDAP_OPT_PROTOCOL_VERSION'] = 'LDAP_VERSION3'; - - } - /* The host name (or list of hosts) for the primary LDAP server. */ - ldap_get_option( $this->_connectionID, LDAP_OPT_HOST_NAME, $version['LDAP_OPT_HOST_NAME'] ); - ldap_get_option( $this->_connectionID, LDAP_OPT_ERROR_NUMBER, $version['LDAP_OPT_ERROR_NUMBER'] ); - ldap_get_option( $this->_connectionID, LDAP_OPT_ERROR_STRING, $version['LDAP_OPT_ERROR_STRING'] ); - ldap_get_option( $this->_connectionID, LDAP_OPT_MATCHED_DN, $version['LDAP_OPT_MATCHED_DN'] ); - - return $this->version = $version; - - } -} - -/*-------------------------------------------------------------------------------------- - Class Name: Recordset ---------------------------------------------------------------------------------------*/ - -class ADORecordSet_ldap extends ADORecordSet{ - - var $databaseType = "ldap"; - var $canSeek = false; - var $_entryID; /* keeps track of the entry resource identifier */ - - function ADORecordSet_ldap($queryID,$mode=false) - { - if ($mode === false) { - global $ADODB_FETCH_MODE; - $mode = $ADODB_FETCH_MODE; - } - switch ($mode) - { - case ADODB_FETCH_NUM: - $this->fetchMode = LDAP_NUM; - break; - case ADODB_FETCH_ASSOC: - $this->fetchMode = LDAP_ASSOC; - break; - case ADODB_FETCH_DEFAULT: - case ADODB_FETCH_BOTH: - default: - $this->fetchMode = LDAP_BOTH; - break; - } - - $this->ADORecordSet($queryID); - } - - function _initrs() - { - /* - This could be teaked to respect the $COUNTRECS directive from ADODB - It's currently being used in the _fetch() function and the - GetAssoc() function - */ - $this->_numOfRows = ldap_count_entries( $this->connection->_connectionID, $this->_queryID ); - - } - - /* - Return whole recordset as a multi-dimensional associative array - */ - function &GetAssoc($force_array = false, $first2cols = false) - { - $records = $this->_numOfRows; - $results = array(); - for ( $i=0; $i < $records; $i++ ) { - foreach ( $this->fields as $k=>$v ) { - if ( is_array( $v ) ) { - if ( $v['count'] == 1 ) { - $results[$i][$k] = $v[0]; - } else { - array_shift( $v ); - $results[$i][$k] = $v; - } - } - } - } - - return $results; - } - - function &GetRowAssoc() - { - $results = array(); - foreach ( $this->fields as $k=>$v ) { - if ( is_array( $v ) ) { - if ( $v['count'] == 1 ) { - $results[$k] = $v[0]; - } else { - array_shift( $v ); - $results[$k] = $v; - } - } - } - - return $results; - } - - function GetRowNums() - { - $results = array(); - foreach ( $this->fields as $k=>$v ) { - static $i = 0; - if (is_array( $v )) { - if ( $v['count'] == 1 ) { - $results[$i] = $v[0]; - } else { - array_shift( $v ); - $results[$i] = $v; - } - $i++; - } - } - return $results; - } - - function _fetch() - { - if ( $this->_currentRow >= $this->_numOfRows && $this->_numOfRows >= 0 ) - return false; - - if ( $this->_currentRow == 0 ) { - $this->_entryID = ldap_first_entry( $this->connection->_connectionID, $this->_queryID ); - } else { - $this->_entryID = ldap_next_entry( $this->connection->_connectionID, $this->_entryID ); - } - - $this->fields = ldap_get_attributes( $this->connection->_connectionID, $this->_entryID ); - $this->_numOfFields = $this->fields['count']; - switch ( $this->fetchMode ) { - - case LDAP_ASSOC: - $this->fields = $this->GetRowAssoc(); - break; - - case LDAP_NUM: - $this->fields = array_merge($this->GetRowNums(),$this->GetRowAssoc()); - break; - - case LDAP_BOTH: - default: - $this->fields = $this->GetRowNums(); - break; - } - return ( is_array( $this->fields ) ); - } - - function _close() { - @ldap_free_result( $this->_queryID ); - $this->_queryID = false; - } - -} -?>
\ No newline at end of file diff --git a/framework/3rdParty/adodb/drivers/adodb-mssql.inc.php b/framework/3rdParty/adodb/drivers/adodb-mssql.inc.php deleted file mode 100644 index 2f5ed415..00000000 --- a/framework/3rdParty/adodb/drivers/adodb-mssql.inc.php +++ /dev/null @@ -1,1024 +0,0 @@ -<?php -/* -V4.81 3 May 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved. - Released under both BSD license and Lesser GPL library license. - Whenever there is any discrepancy between the two licenses, - the BSD license will take precedence. -Set tabs to 4 for best viewing. - - Latest version is available at http://adodb.sourceforge.net - - Native mssql driver. Requires mssql client. Works on Windows. - To configure for Unix, see - http://phpbuilder.com/columns/alberto20000919.php3 - -*/ - -// security - hide paths -if (!defined('ADODB_DIR')) die(); - -//---------------------------------------------------------------- -// MSSQL returns dates with the format Oct 13 2002 or 13 Oct 2002 -// and this causes tons of problems because localized versions of -// MSSQL will return the dates in dmy or mdy order; and also the -// month strings depends on what language has been configured. The -// following two variables allow you to control the localization -// settings - Ugh. -// -// MORE LOCALIZATION INFO -// ---------------------- -// To configure datetime, look for and modify sqlcommn.loc, -// typically found in c:\mssql\install -// Also read : -// http://support.microsoft.com/default.aspx?scid=kb;EN-US;q220918 -// Alternatively use: -// CONVERT(char(12),datecol,120) -//---------------------------------------------------------------- - - -// has datetime converstion to YYYY-MM-DD format, and also mssql_fetch_assoc -if (ADODB_PHPVER >= 0x4300) { -// docs say 4.2.0, but testing shows only since 4.3.0 does it work! - ini_set('mssql.datetimeconvert',0); -} else { -global $ADODB_mssql_mths; // array, months must be upper-case - - - $ADODB_mssql_date_order = 'mdy'; - $ADODB_mssql_mths = array( - 'JAN'=>1,'FEB'=>2,'MAR'=>3,'APR'=>4,'MAY'=>5,'JUN'=>6, - 'JUL'=>7,'AUG'=>8,'SEP'=>9,'OCT'=>10,'NOV'=>11,'DEC'=>12); -} - -//--------------------------------------------------------------------------- -// Call this to autoset $ADODB_mssql_date_order at the beginning of your code, -// just after you connect to the database. Supports mdy and dmy only. -// Not required for PHP 4.2.0 and above. -function AutoDetect_MSSQL_Date_Order($conn) -{ -global $ADODB_mssql_date_order; - $adate = $conn->GetOne('select getdate()'); - if ($adate) { - $anum = (int) $adate; - if ($anum > 0) { - if ($anum > 31) { - //ADOConnection::outp( "MSSQL: YYYY-MM-DD date format not supported currently"); - } else - $ADODB_mssql_date_order = 'dmy'; - } else - $ADODB_mssql_date_order = 'mdy'; - } -} - -class ADODB_mssql extends ADOConnection { - var $databaseType = "mssql"; - var $dataProvider = "mssql"; - var $replaceQuote = "''"; // string to use to replace quotes - var $fmtDate = "'Y-m-d'"; - var $fmtTimeStamp = "'Y-m-d H:i:s'"; - var $hasInsertID = true; - var $substr = "substring"; - var $length = 'len'; - var $hasAffectedRows = true; - var $metaDatabasesSQL = "select name from sysdatabases where name <> 'master'"; - var $metaTablesSQL="select name,case when type='U' then 'T' else 'V' end from sysobjects where (type='U' or type='V') and (name not in ('sysallocations','syscolumns','syscomments','sysdepends','sysfilegroups','sysfiles','sysfiles1','sysforeignkeys','sysfulltextcatalogs','sysindexes','sysindexkeys','sysmembers','sysobjects','syspermissions','sysprotects','sysreferences','systypes','sysusers','sysalternates','sysconstraints','syssegments','REFERENTIAL_CONSTRAINTS','CHECK_CONSTRAINTS','CONSTRAINT_TABLE_USAGE','CONSTRAINT_COLUMN_USAGE','VIEWS','VIEW_TABLE_USAGE','VIEW_COLUMN_USAGE','SCHEMATA','TABLES','TABLE_CONSTRAINTS','TABLE_PRIVILEGES','COLUMNS','COLUMN_DOMAIN_USAGE','COLUMN_PRIVILEGES','DOMAINS','DOMAIN_CONSTRAINTS','KEY_COLUMN_USAGE','dtproperties'))"; - var $metaColumnsSQL = # xtype==61 is datetime -"select c.name,t.name,c.length, - (case when c.xusertype=61 then 0 else c.xprec end), - (case when c.xusertype=61 then 0 else c.xscale end) - from syscolumns c join systypes t on t.xusertype=c.xusertype join sysobjects o on o.id=c.id where o.name='%s'"; - var $hasTop = 'top'; // support mssql SELECT TOP 10 * FROM TABLE - var $hasGenID = true; - var $sysDate = 'convert(datetime,convert(char,GetDate(),102),102)'; - var $sysTimeStamp = 'GetDate()'; - var $_has_mssql_init; - var $maxParameterLen = 4000; - var $arrayClass = 'ADORecordSet_array_mssql'; - var $uniqueSort = true; - var $leftOuter = '*='; - var $rightOuter = '=*'; - var $ansiOuter = true; // for mssql7 or later - var $poorAffectedRows = true; - var $identitySQL = 'select @@IDENTITY'; // 'select SCOPE_IDENTITY'; # for mssql 2000 - var $uniqueOrderBy = true; - var $_bindInputArray = true; - - function ADODB_mssql() - { - $this->_has_mssql_init = (strnatcmp(PHP_VERSION,'4.1.0')>=0); - } - - function ServerInfo() - { - global $ADODB_FETCH_MODE; - - $stmt = $this->PrepareSP('sp_server_info'); - $val = 2; - if ($this->fetchMode === false) { - $savem = $ADODB_FETCH_MODE; - $ADODB_FETCH_MODE = ADODB_FETCH_NUM; - } else - $savem = $this->SetFetchMode(ADODB_FETCH_NUM); - - - $this->Parameter($stmt,$val,'attribute_id'); - $row = $this->GetRow($stmt); - - //$row = $this->GetRow("execute sp_server_info 2"); - - - if ($this->fetchMode === false) { - $ADODB_FETCH_MODE = $savem; - } else - $this->SetFetchMode($savem); - - $arr['description'] = $row[2]; - $arr['version'] = ADOConnection::_findvers($arr['description']); - return $arr; - } - - function IfNull( $field, $ifNull ) - { - return " ISNULL($field, $ifNull) "; // if MS SQL Server - } - - function _insertid() - { - // SCOPE_IDENTITY() - // Returns the last IDENTITY value inserted into an IDENTITY column in - // the same scope. A scope is a module -- a stored procedure, trigger, - // function, or batch. Thus, two statements are in the same scope if - // they are in the same stored procedure, function, or batch. - return $this->GetOne($this->identitySQL); - } - - function _affectedrows() - { - return $this->GetOne('select @@rowcount'); - } - - var $_dropSeqSQL = "drop table %s"; - - function CreateSequence($seq='adodbseq',$start=1) - { - - $this->Execute('BEGIN TRANSACTION adodbseq'); - $start -= 1; - $this->Execute("create table $seq (id float(53))"); - $ok = $this->Execute("insert into $seq with (tablock,holdlock) values($start)"); - if (!$ok) { - $this->Execute('ROLLBACK TRANSACTION adodbseq'); - return false; - } - $this->Execute('COMMIT TRANSACTION adodbseq'); - return true; - } - - function GenID($seq='adodbseq',$start=1) - { - //$this->debug=1; - $this->Execute('BEGIN TRANSACTION adodbseq'); - $ok = $this->Execute("update $seq with (tablock,holdlock) set id = id + 1"); - if (!$ok) { - $this->Execute("create table $seq (id float(53))"); - $ok = $this->Execute("insert into $seq with (tablock,holdlock) values($start)"); - if (!$ok) { - $this->Execute('ROLLBACK TRANSACTION adodbseq'); - return false; - } - $this->Execute('COMMIT TRANSACTION adodbseq'); - return $start; - } - $num = $this->GetOne("select id from $seq"); - $this->Execute('COMMIT TRANSACTION adodbseq'); - return $num; - - // in old implementation, pre 1.90, we returned GUID... - //return $this->GetOne("SELECT CONVERT(varchar(255), NEWID()) AS 'Char'"); - } - - - function &SelectLimit($sql,$nrows=-1,$offset=-1, $inputarr=false,$secs2cache=0) - { - if ($nrows > 0 && $offset <= 0) { - $sql = preg_replace( - '/(^\s*select\s+(distinctrow|distinct)?)/i','\\1 '.$this->hasTop." $nrows ",$sql); - $rs =& $this->Execute($sql,$inputarr); - } else - $rs =& ADOConnection::SelectLimit($sql,$nrows,$offset,$inputarr,$secs2cache); - - return $rs; - } - - - // Format date column in sql string given an input format that understands Y M D - function SQLDate($fmt, $col=false) - { - if (!$col) $col = $this->sysTimeStamp; - $s = ''; - - $len = strlen($fmt); - for ($i=0; $i < $len; $i++) { - if ($s) $s .= '+'; - $ch = $fmt[$i]; - switch($ch) { - case 'Y': - case 'y': - $s .= "datename(yyyy,$col)"; - break; - case 'M': - $s .= "convert(char(3),$col,0)"; - break; - case 'm': - $s .= "replace(str(month($col),2),' ','0')"; - break; - case 'Q': - case 'q': - $s .= "datename(quarter,$col)"; - break; - case 'D': - case 'd': - $s .= "replace(str(day($col),2),' ','0')"; - break; - case 'h': - $s .= "substring(convert(char(14),$col,0),13,2)"; - break; - - case 'H': - $s .= "replace(str(datepart(hh,$col),2),' ','0')"; - break; - - case 'i': - $s .= "replace(str(datepart(mi,$col),2),' ','0')"; - break; - case 's': - $s .= "replace(str(datepart(ss,$col),2),' ','0')"; - break; - case 'a': - case 'A': - $s .= "substring(convert(char(19),$col,0),18,2)"; - break; - - default: - if ($ch == '\\') { - $i++; - $ch = substr($fmt,$i,1); - } - $s .= $this->qstr($ch); - break; - } - } - return $s; - } - - - function BeginTrans() - { - if ($this->transOff) return true; - $this->transCnt += 1; - $this->Execute('BEGIN TRAN'); - return true; - } - - function CommitTrans($ok=true) - { - if ($this->transOff) return true; - if (!$ok) return $this->RollbackTrans(); - if ($this->transCnt) $this->transCnt -= 1; - $this->Execute('COMMIT TRAN'); - return true; - } - function RollbackTrans() - { - if ($this->transOff) return true; - if ($this->transCnt) $this->transCnt -= 1; - $this->Execute('ROLLBACK TRAN'); - return true; - } - - /* - Usage: - - $this->BeginTrans(); - $this->RowLock('table1,table2','table1.id=33 and table2.id=table1.id'); # lock row 33 for both tables - - # some operation on both tables table1 and table2 - - $this->CommitTrans(); - - See http://www.swynk.com/friends/achigrik/SQL70Locks.asp - */ - function RowLock($tables,$where,$flds='top 1 null as ignore') - { - if (!$this->transCnt) $this->BeginTrans(); - return $this->GetOne("select $flds from $tables with (ROWLOCK,HOLDLOCK) where $where"); - } - - - function &MetaIndexes($table,$primary=false) - { - $table = $this->qstr($table); - - $sql = "SELECT i.name AS ind_name, C.name AS col_name, USER_NAME(O.uid) AS Owner, c.colid, k.Keyno, - CASE WHEN I.indid BETWEEN 1 AND 254 AND (I.status & 2048 = 2048 OR I.Status = 16402 AND O.XType = 'V') THEN 1 ELSE 0 END AS IsPK, - CASE WHEN I.status & 2 = 2 THEN 1 ELSE 0 END AS IsUnique - FROM dbo.sysobjects o INNER JOIN dbo.sysindexes I ON o.id = i.id - INNER JOIN dbo.sysindexkeys K ON I.id = K.id AND I.Indid = K.Indid - INNER JOIN dbo.syscolumns c ON K.id = C.id AND K.colid = C.Colid - WHERE LEFT(i.name, 8) <> '_WA_Sys_' AND o.status >= 0 AND O.Name LIKE $table - ORDER BY O.name, I.Name, K.keyno"; - - global $ADODB_FETCH_MODE; - $save = $ADODB_FETCH_MODE; - $ADODB_FETCH_MODE = ADODB_FETCH_NUM; - if ($this->fetchMode !== FALSE) { - $savem = $this->SetFetchMode(FALSE); - } - - $rs = $this->Execute($sql); - if (isset($savem)) { - $this->SetFetchMode($savem); - } - $ADODB_FETCH_MODE = $save; - - if (!is_object($rs)) { - return FALSE; - } - - $indexes = array(); - while ($row = $rs->FetchRow()) { - if (!$primary && $row[5]) continue; - - $indexes[$row[0]]['unique'] = $row[6]; - $indexes[$row[0]]['columns'][] = $row[1]; - } - return $indexes; - } - - function MetaForeignKeys($table, $owner=false, $upper=false) - { - global $ADODB_FETCH_MODE; - - $save = $ADODB_FETCH_MODE; - $ADODB_FETCH_MODE = ADODB_FETCH_NUM; - $table = $this->qstr(strtoupper($table)); - - $sql = -"select object_name(constid) as constraint_name, - col_name(fkeyid, fkey) as column_name, - object_name(rkeyid) as referenced_table_name, - col_name(rkeyid, rkey) as referenced_column_name -from sysforeignkeys -where upper(object_name(fkeyid)) = $table -order by constraint_name, referenced_table_name, keyno"; - - $constraints =& $this->GetArray($sql); - - $ADODB_FETCH_MODE = $save; - - $arr = false; - foreach($constraints as $constr) { - //print_r($constr); - $arr[$constr[0]][$constr[2]][] = $constr[1].'='.$constr[3]; - } - if (!$arr) return false; - - $arr2 = false; - - foreach($arr as $k => $v) { - foreach($v as $a => $b) { - if ($upper) $a = strtoupper($a); - $arr2[$a] = $b; - } - } - return $arr2; - } - - //From: Fernando Moreira <FMoreira@imediata.pt> - function MetaDatabases() - { - if(@mssql_select_db("master")) { - $qry=$this->metaDatabasesSQL; - if($rs=@mssql_query($qry)){ - $tmpAr=$ar=array(); - while($tmpAr=@mssql_fetch_row($rs)) - $ar[]=$tmpAr[0]; - @mssql_select_db($this->database); - if(sizeof($ar)) - return($ar); - else - return(false); - } else { - @mssql_select_db($this->database); - return(false); - } - } - return(false); - } - - // "Stein-Aksel Basma" <basma@accelero.no> - // tested with MSSQL 2000 - function &MetaPrimaryKeys($table) - { - global $ADODB_FETCH_MODE; - - $schema = ''; - $this->_findschema($table,$schema); - if (!$schema) $schema = $this->database; - if ($schema) $schema = "and k.table_catalog like '$schema%'"; - - $sql = "select distinct k.column_name,ordinal_position from information_schema.key_column_usage k, - information_schema.table_constraints tc - where tc.constraint_name = k.constraint_name and tc.constraint_type = - 'PRIMARY KEY' and k.table_name = '$table' $schema order by ordinal_position "; - - $savem = $ADODB_FETCH_MODE; - $ADODB_FETCH_MODE = ADODB_FETCH_NUM; - $a = $this->GetCol($sql); - $ADODB_FETCH_MODE = $savem; - - if ($a && sizeof($a)>0) return $a; - $false = false; - return $false; - } - - - function &MetaTables($ttype=false,$showSchema=false,$mask=false) - { - if ($mask) { - $save = $this->metaTablesSQL; - $mask = $this->qstr(($mask)); - $this->metaTablesSQL .= " AND name like $mask"; - } - $ret =& ADOConnection::MetaTables($ttype,$showSchema); - - if ($mask) { - $this->metaTablesSQL = $save; - } - return $ret; - } - - function SelectDB($dbName) - { - $this->database = $dbName; - $this->databaseName = $dbName; # obsolete, retained for compat with older adodb versions - if ($this->_connectionID) { - return @mssql_select_db($dbName); - } - else return false; - } - - function ErrorMsg() - { - if (empty($this->_errorMsg)){ - $this->_errorMsg = mssql_get_last_message(); - } - return $this->_errorMsg; - } - - function ErrorNo() - { - if ($this->_logsql && $this->_errorCode !== false) return $this->_errorCode; - if (empty($this->_errorMsg)) { - $this->_errorMsg = mssql_get_last_message(); - } - $id = @mssql_query("select @@ERROR",$this->_connectionID); - if (!$id) return false; - $arr = mssql_fetch_array($id); - @mssql_free_result($id); - if (is_array($arr)) return $arr[0]; - else return -1; - } - - // returns true or false - function _connect($argHostname, $argUsername, $argPassword, $argDatabasename) - { - if (!function_exists('mssql_pconnect')) return null; - $this->_connectionID = mssql_connect($argHostname,$argUsername,$argPassword); - if ($this->_connectionID === false) return false; - if ($argDatabasename) return $this->SelectDB($argDatabasename); - return true; - } - - - // returns true or false - function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename) - { - if (!function_exists('mssql_pconnect')) return null; - $this->_connectionID = mssql_pconnect($argHostname,$argUsername,$argPassword); - if ($this->_connectionID === false) return false; - - // persistent connections can forget to rollback on crash, so we do it here. - if ($this->autoRollback) { - $cnt = $this->GetOne('select @@TRANCOUNT'); - while (--$cnt >= 0) $this->Execute('ROLLBACK TRAN'); - } - if ($argDatabasename) return $this->SelectDB($argDatabasename); - return true; - } - - function Prepare($sql) - { - $sqlarr = explode('?',$sql); - if (sizeof($sqlarr) <= 1) return $sql; - $sql2 = $sqlarr[0]; - for ($i = 1, $max = sizeof($sqlarr); $i < $max; $i++) { - $sql2 .= '@P'.($i-1) . $sqlarr[$i]; - } - return array($sql,$this->qstr($sql2),$max); - } - - function PrepareSP($sql) - { - if (!$this->_has_mssql_init) { - ADOConnection::outp( "PrepareSP: mssql_init only available since PHP 4.1.0"); - return $sql; - } - $stmt = mssql_init($sql,$this->_connectionID); - if (!$stmt) return $sql; - return array($sql,$stmt); - } - - // returns concatenated string - // MSSQL requires integers to be cast as strings - // automatically cast every datatype to VARCHAR(255) - // @author David Rogers (introspectshun) - function Concat() - { - $s = ""; - $arr = func_get_args(); - - // Split single record on commas, if possible - if (sizeof($arr) == 1) { - foreach ($arr as $arg) { - $args = explode(',', $arg); - } - $arr = $args; - } - - array_walk($arr, create_function('&$v', '$v = "CAST(" . $v . " AS VARCHAR(255))";')); - $s = implode('+',$arr); - if (sizeof($arr) > 0) return "$s"; - - return ''; - } - - /* - Usage: - $stmt = $db->PrepareSP('SP_RUNSOMETHING'); -- takes 2 params, @myid and @group - - # note that the parameter does not have @ in front! - $db->Parameter($stmt,$id,'myid'); - $db->Parameter($stmt,$group,'group',false,64); - $db->Execute($stmt); - - @param $stmt Statement returned by Prepare() or PrepareSP(). - @param $var PHP variable to bind to. Can set to null (for isNull support). - @param $name Name of stored procedure variable name to bind to. - @param [$isOutput] Indicates direction of parameter 0/false=IN 1=OUT 2= IN/OUT. This is ignored in oci8. - @param [$maxLen] Holds an maximum length of the variable. - @param [$type] The data type of $var. Legal values depend on driver. - - See mssql_bind documentation at php.net. - */ - function Parameter(&$stmt, &$var, $name, $isOutput=false, $maxLen=4000, $type=false) - { - if (!$this->_has_mssql_init) { - ADOConnection::outp( "Parameter: mssql_bind only available since PHP 4.1.0"); - return false; - } - - $isNull = is_null($var); // php 4.0.4 and above... - - if ($type === false) - switch(gettype($var)) { - default: - case 'string': $type = SQLCHAR; break; - case 'double': $type = SQLFLT8; break; - case 'integer': $type = SQLINT4; break; - case 'boolean': $type = SQLINT1; break; # SQLBIT not supported in 4.1.0 - } - - if ($this->debug) { - $prefix = ($isOutput) ? 'Out' : 'In'; - $ztype = (empty($type)) ? 'false' : $type; - ADOConnection::outp( "{$prefix}Parameter(\$stmt, \$php_var='$var', \$name='$name', \$maxLen=$maxLen, \$type=$ztype);"); - } - /* - See http://phplens.com/lens/lensforum/msgs.php?id=7231 - - RETVAL is HARD CODED into php_mssql extension: - The return value (a long integer value) is treated like a special OUTPUT parameter, - called "RETVAL" (without the @). See the example at mssql_execute to - see how it works. - type: one of this new supported PHP constants. - SQLTEXT, SQLVARCHAR,SQLCHAR, SQLINT1,SQLINT2, SQLINT4, SQLBIT,SQLFLT8 - */ - if ($name !== 'RETVAL') $name = '@'.$name; - return mssql_bind($stmt[1], $name, $var, $type, $isOutput, $isNull, $maxLen); - } - - /* - Unfortunately, it appears that mssql cannot handle varbinary > 255 chars - So all your blobs must be of type "image". - - Remember to set in php.ini the following... - - ; Valid range 0 - 2147483647. Default = 4096. - mssql.textlimit = 0 ; zero to pass through - - ; Valid range 0 - 2147483647. Default = 4096. - mssql.textsize = 0 ; zero to pass through - */ - function UpdateBlob($table,$column,$val,$where,$blobtype='BLOB') - { - - if (strtoupper($blobtype) == 'CLOB') { - $sql = "UPDATE $table SET $column='" . $val . "' WHERE $where"; - return $this->Execute($sql) != false; - } - $sql = "UPDATE $table SET $column=0x".bin2hex($val)." WHERE $where"; - return $this->Execute($sql) != false; - } - - // returns query ID if successful, otherwise false - function _query($sql,$inputarr) - { - $this->_errorMsg = false; - if (is_array($inputarr)) { - - # bind input params with sp_executesql: - # see http://www.quest-pipelines.com/newsletter-v3/0402_F.htm - # works only with sql server 7 and newer - if (!is_array($sql)) $sql = $this->Prepare($sql); - $params = ''; - $decl = ''; - $i = 0; - foreach($inputarr as $v) { - if ($decl) { - $decl .= ', '; - $params .= ', '; - } - if (is_string($v)) { - $len = strlen($v); - if ($len == 0) $len = 1; - - if ($len > 4000 ) { - // NVARCHAR is max 4000 chars. Let's use NTEXT - $decl .= "@P$i NTEXT"; - } else { - $decl .= "@P$i NVARCHAR($len)"; - } - - $params .= "@P$i=N". (strncmp($v,"'",1)==0? $v : $this->qstr($v)); - } else if (is_integer($v)) { - $decl .= "@P$i INT"; - $params .= "@P$i=".$v; - } else if (is_float($v)) { - $decl .= "@P$i FLOAT"; - $params .= "@P$i=".$v; - } else if (is_bool($v)) { - $decl .= "@P$i INT"; # Used INT just in case BIT in not supported on the user's MSSQL version. It will cast appropriately. - $params .= "@P$i=".(($v)?'1':'0'); # True == 1 in MSSQL BIT fields and acceptable for storing logical true in an int field - } else { - $decl .= "@P$i CHAR"; # Used char because a type is required even when the value is to be NULL. - $params .= "@P$i=NULL"; - } - $i += 1; - } - $decl = $this->qstr($decl); - if ($this->debug) ADOConnection::outp("<font size=-1>sp_executesql N{$sql[1]},N$decl,$params</font>"); - $rez = mssql_query("sp_executesql N{$sql[1]},N$decl,$params"); - - } else if (is_array($sql)) { - # PrepareSP() - $rez = mssql_execute($sql[1]); - - } else { - $rez = mssql_query($sql,$this->_connectionID); - } - return $rez; - } - - // returns true or false - function _close() - { - if ($this->transCnt) $this->RollbackTrans(); - $rez = @mssql_close($this->_connectionID); - $this->_connectionID = false; - return $rez; - } - - // mssql uses a default date like Dec 30 2000 12:00AM - function UnixDate($v) - { - return ADORecordSet_array_mssql::UnixDate($v); - } - - function UnixTimeStamp($v) - { - return ADORecordSet_array_mssql::UnixTimeStamp($v); - } -} - -/*-------------------------------------------------------------------------------------- - Class Name: Recordset ---------------------------------------------------------------------------------------*/ - -class ADORecordset_mssql extends ADORecordSet { - - var $databaseType = "mssql"; - var $canSeek = true; - var $hasFetchAssoc; // see http://phplens.com/lens/lensforum/msgs.php?id=6083 - // _mths works only in non-localised system - - function ADORecordset_mssql($id,$mode=false) - { - // freedts check... - $this->hasFetchAssoc = function_exists('mssql_fetch_assoc'); - - if ($mode === false) { - global $ADODB_FETCH_MODE; - $mode = $ADODB_FETCH_MODE; - - } - $this->fetchMode = $mode; - return $this->ADORecordSet($id,$mode); - } - - - function _initrs() - { - GLOBAL $ADODB_COUNTRECS; - $this->_numOfRows = ($ADODB_COUNTRECS)? @mssql_num_rows($this->_queryID):-1; - $this->_numOfFields = @mssql_num_fields($this->_queryID); - } - - - //Contributed by "Sven Axelsson" <sven.axelsson@bokochwebb.se> - // get next resultset - requires PHP 4.0.5 or later - function NextRecordSet() - { - if (!mssql_next_result($this->_queryID)) return false; - $this->_inited = false; - $this->bind = false; - $this->_currentRow = -1; - $this->Init(); - return true; - } - - /* Use associative array to get fields array */ - function Fields($colname) - { - if ($this->fetchMode != ADODB_FETCH_NUM) return $this->fields[$colname]; - if (!$this->bind) { - $this->bind = array(); - for ($i=0; $i < $this->_numOfFields; $i++) { - $o = $this->FetchField($i); - $this->bind[strtoupper($o->name)] = $i; - } - } - - return $this->fields[$this->bind[strtoupper($colname)]]; - } - - /* Returns: an object containing field information. - Get column information in the Recordset object. fetchField() can be used in order to obtain information about - fields in a certain query result. If the field offset isn't specified, the next field that wasn't yet retrieved by - fetchField() is retrieved. */ - - function &FetchField($fieldOffset = -1) - { - if ($fieldOffset != -1) { - $f = @mssql_fetch_field($this->_queryID, $fieldOffset); - } - else if ($fieldOffset == -1) { /* The $fieldOffset argument is not provided thus its -1 */ - $f = @mssql_fetch_field($this->_queryID); - } - $false = false; - if (empty($f)) return $false; - return $f; - } - - function _seek($row) - { - return @mssql_data_seek($this->_queryID, $row); - } - - // speedup - function MoveNext() - { - if ($this->EOF) return false; - - $this->_currentRow++; - - if ($this->fetchMode & ADODB_FETCH_ASSOC) { - if ($this->fetchMode & ADODB_FETCH_NUM) { - //ADODB_FETCH_BOTH mode - $this->fields = @mssql_fetch_array($this->_queryID); - } - else { - if ($this->hasFetchAssoc) {// only for PHP 4.2.0 or later - $this->fields = @mssql_fetch_assoc($this->_queryID); - } else { - $flds = @mssql_fetch_array($this->_queryID); - if (is_array($flds)) { - $fassoc = array(); - foreach($flds as $k => $v) { - if (is_numeric($k)) continue; - $fassoc[$k] = $v; - } - $this->fields = $fassoc; - } else - $this->fields = false; - } - } - - if (is_array($this->fields)) { - if (ADODB_ASSOC_CASE == 0) { - foreach($this->fields as $k=>$v) { - $this->fields[strtolower($k)] = $v; - } - } else if (ADODB_ASSOC_CASE == 1) { - foreach($this->fields as $k=>$v) { - $this->fields[strtoupper($k)] = $v; - } - } - } - } else { - $this->fields = @mssql_fetch_row($this->_queryID); - } - if ($this->fields) return true; - $this->EOF = true; - - return false; - } - - - // INSERT UPDATE DELETE returns false even if no error occurs in 4.0.4 - // also the date format has been changed from YYYY-mm-dd to dd MMM YYYY in 4.0.4. Idiot! - function _fetch($ignore_fields=false) - { - if ($this->fetchMode & ADODB_FETCH_ASSOC) { - if ($this->fetchMode & ADODB_FETCH_NUM) { - //ADODB_FETCH_BOTH mode - $this->fields = @mssql_fetch_array($this->_queryID); - } else { - if ($this->hasFetchAssoc) // only for PHP 4.2.0 or later - $this->fields = @mssql_fetch_assoc($this->_queryID); - else { - $this->fields = @mssql_fetch_array($this->_queryID); - if (@is_array($$this->fields)) { - $fassoc = array(); - foreach($$this->fields as $k => $v) { - if (is_integer($k)) continue; - $fassoc[$k] = $v; - } - $this->fields = $fassoc; - } - } - } - - if (!$this->fields) { - } else if (ADODB_ASSOC_CASE == 0) { - foreach($this->fields as $k=>$v) { - $this->fields[strtolower($k)] = $v; - } - } else if (ADODB_ASSOC_CASE == 1) { - foreach($this->fields as $k=>$v) { - $this->fields[strtoupper($k)] = $v; - } - } - } else { - $this->fields = @mssql_fetch_row($this->_queryID); - } - return $this->fields; - } - - /* close() only needs to be called if you are worried about using too much memory while your script - is running. All associated result memory for the specified result identifier will automatically be freed. */ - - function _close() - { - $rez = mssql_free_result($this->_queryID); - $this->_queryID = false; - return $rez; - } - // mssql uses a default date like Dec 30 2000 12:00AM - function UnixDate($v) - { - return ADORecordSet_array_mssql::UnixDate($v); - } - - function UnixTimeStamp($v) - { - return ADORecordSet_array_mssql::UnixTimeStamp($v); - } - -} - - -class ADORecordSet_array_mssql extends ADORecordSet_array { - function ADORecordSet_array_mssql($id=-1,$mode=false) - { - $this->ADORecordSet_array($id,$mode); - } - - // mssql uses a default date like Dec 30 2000 12:00AM - function UnixDate($v) - { - - if (is_numeric(substr($v,0,1)) && ADODB_PHPVER >= 0x4200) return parent::UnixDate($v); - - global $ADODB_mssql_mths,$ADODB_mssql_date_order; - - //Dec 30 2000 12:00AM - if ($ADODB_mssql_date_order == 'dmy') { - if (!preg_match( "|^([0-9]{1,2})[-/\. ]+([A-Za-z]{3})[-/\. ]+([0-9]{4})|" ,$v, $rr)) { - return parent::UnixDate($v); - } - if ($rr[3] <= TIMESTAMP_FIRST_YEAR) return 0; - - $theday = $rr[1]; - $themth = substr(strtoupper($rr[2]),0,3); - } else { - if (!preg_match( "|^([A-Za-z]{3})[-/\. ]+([0-9]{1,2})[-/\. ]+([0-9]{4})|" ,$v, $rr)) { - return parent::UnixDate($v); - } - if ($rr[3] <= TIMESTAMP_FIRST_YEAR) return 0; - - $theday = $rr[2]; - $themth = substr(strtoupper($rr[1]),0,3); - } - $themth = $ADODB_mssql_mths[$themth]; - if ($themth <= 0) return false; - // h-m-s-MM-DD-YY - return mktime(0,0,0,$themth,$theday,$rr[3]); - } - - function UnixTimeStamp($v) - { - - if (is_numeric(substr($v,0,1)) && ADODB_PHPVER >= 0x4200) return parent::UnixTimeStamp($v); - - global $ADODB_mssql_mths,$ADODB_mssql_date_order; - - //Dec 30 2000 12:00AM - if ($ADODB_mssql_date_order == 'dmy') { - if (!preg_match( "|^([0-9]{1,2})[-/\. ]+([A-Za-z]{3})[-/\. ]+([0-9]{4}) +([0-9]{1,2}):([0-9]{1,2}) *([apAP]{0,1})|" - ,$v, $rr)) return parent::UnixTimeStamp($v); - if ($rr[3] <= TIMESTAMP_FIRST_YEAR) return 0; - - $theday = $rr[1]; - $themth = substr(strtoupper($rr[2]),0,3); - } else { - if (!preg_match( "|^([A-Za-z]{3})[-/\. ]+([0-9]{1,2})[-/\. ]+([0-9]{4}) +([0-9]{1,2}):([0-9]{1,2}) *([apAP]{0,1})|" - ,$v, $rr)) return parent::UnixTimeStamp($v); - if ($rr[3] <= TIMESTAMP_FIRST_YEAR) return 0; - - $theday = $rr[2]; - $themth = substr(strtoupper($rr[1]),0,3); - } - - $themth = $ADODB_mssql_mths[$themth]; - if ($themth <= 0) return false; - - switch (strtoupper($rr[6])) { - case 'P': - if ($rr[4]<12) $rr[4] += 12; - break; - case 'A': - if ($rr[4]==12) $rr[4] = 0; - break; - default: - break; - } - // h-m-s-MM-DD-YY - return mktime($rr[4],$rr[5],0,$themth,$theday,$rr[3]); - } -} - -/* -Code Example 1: - -select object_name(constid) as constraint_name, - object_name(fkeyid) as table_name, - col_name(fkeyid, fkey) as column_name, - object_name(rkeyid) as referenced_table_name, - col_name(rkeyid, rkey) as referenced_column_name -from sysforeignkeys -where object_name(fkeyid) = x -order by constraint_name, table_name, referenced_table_name, keyno - -Code Example 2: -select constraint_name, - column_name, - ordinal_position -from information_schema.key_column_usage -where constraint_catalog = db_name() -and table_name = x -order by constraint_name, ordinal_position - -http://www.databasejournal.com/scripts/article.php/1440551 -*/ - -?>
\ No newline at end of file diff --git a/framework/3rdParty/adodb/drivers/adodb-mssqlpo.inc.php b/framework/3rdParty/adodb/drivers/adodb-mssqlpo.inc.php deleted file mode 100644 index dc2441c1..00000000 --- a/framework/3rdParty/adodb/drivers/adodb-mssqlpo.inc.php +++ /dev/null @@ -1,62 +0,0 @@ -<?php -/** -* @version V4.81 3 May 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved. -* Released under both BSD license and Lesser GPL library license. -* Whenever there is any discrepancy between the two licenses, -* the BSD license will take precedence. -* -* Set tabs to 4 for best viewing. -* -* Latest version is available at http://php.weblogs.com -* -* Portable MSSQL Driver that supports || instead of + -* -*/ - -// security - hide paths -if (!defined('ADODB_DIR')) die(); - - -/* - The big difference between mssqlpo and it's parent mssql is that mssqlpo supports - the more standard || string concatenation operator. -*/ - -include_once(ADODB_DIR.'/drivers/adodb-mssql.inc.php'); - -class ADODB_mssqlpo extends ADODB_mssql { - var $databaseType = "mssqlpo"; - var $concat_operator = '||'; - - function ADODB_mssqlpo() - { - ADODB_mssql::ADODB_mssql(); - } - - function PrepareSP($sql) - { - if (!$this->_has_mssql_init) { - ADOConnection::outp( "PrepareSP: mssql_init only available since PHP 4.1.0"); - return $sql; - } - if (is_string($sql)) $sql = str_replace('||','+',$sql); - $stmt = mssql_init($sql,$this->_connectionID); - if (!$stmt) return $sql; - return array($sql,$stmt); - } - - function _query($sql,$inputarr) - { - if (is_string($sql)) $sql = str_replace('||','+',$sql); - return ADODB_mssql::_query($sql,$inputarr); - } -} - -class ADORecordset_mssqlpo extends ADORecordset_mssql { - var $databaseType = "mssqlpo"; - function ADORecordset_mssqlpo($id,$mode=false) - { - $this->ADORecordset_mssql($id,$mode); - } -} -?>
\ No newline at end of file diff --git a/framework/3rdParty/adodb/drivers/adodb-mysql.inc.php b/framework/3rdParty/adodb/drivers/adodb-mysql.inc.php deleted file mode 100644 index c95e025a..00000000 --- a/framework/3rdParty/adodb/drivers/adodb-mysql.inc.php +++ /dev/null @@ -1,776 +0,0 @@ -<?php -/* -V4.81 3 May 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved. - Released under both BSD license and Lesser GPL library license. - Whenever there is any discrepancy between the two licenses, - the BSD license will take precedence. - Set tabs to 8. - - MySQL code that does not support transactions. Use mysqlt if you need transactions. - Requires mysql client. Works on Windows and Unix. - - 28 Feb 2001: MetaColumns bug fix - suggested by Freek Dijkstra (phpeverywhere@macfreek.com) -*/ - -// security - hide paths -if (!defined('ADODB_DIR')) die(); - -if (! defined("_ADODB_MYSQL_LAYER")) { - define("_ADODB_MYSQL_LAYER", 1 ); - -class ADODB_mysql extends ADOConnection { - var $databaseType = 'mysql'; - var $dataProvider = 'mysql'; - var $hasInsertID = true; - var $hasAffectedRows = true; - var $metaTablesSQL = "SHOW TABLES"; - var $metaColumnsSQL = "SHOW COLUMNS FROM %s"; - var $fmtTimeStamp = "'Y-m-d H:i:s'"; - var $hasLimit = true; - var $hasMoveFirst = true; - var $hasGenID = true; - var $isoDates = true; // accepts dates in ISO format - var $sysDate = 'CURDATE()'; - var $sysTimeStamp = 'NOW()'; - var $hasTransactions = false; - var $forceNewConnect = false; - var $poorAffectedRows = true; - var $clientFlags = 0; - var $substr = "substring"; - var $nameQuote = '`'; /// string to use to quote identifiers and names - var $compat323 = false; // true if compat with mysql 3.23 - - function ADODB_mysql() - { - if (defined('ADODB_EXTENSION')) $this->rsPrefix .= 'ext_'; - } - - function ServerInfo() - { - $arr['description'] = ADOConnection::GetOne("select version()"); - $arr['version'] = ADOConnection::_findvers($arr['description']); - return $arr; - } - - function IfNull( $field, $ifNull ) - { - return " IFNULL($field, $ifNull) "; // if MySQL - } - - - function &MetaTables($ttype=false,$showSchema=false,$mask=false) - { - $save = $this->metaTablesSQL; - if ($showSchema && is_string($showSchema)) { - $this->metaTablesSQL .= " from $showSchema"; - } - - if ($mask) { - $mask = $this->qstr($mask); - $this->metaTablesSQL .= " like $mask"; - } - $ret =& ADOConnection::MetaTables($ttype,$showSchema); - - $this->metaTablesSQL = $save; - return $ret; - } - - - function &MetaIndexes ($table, $primary = FALSE, $owner=false) - { - // save old fetch mode - global $ADODB_FETCH_MODE; - - $false = false; - $save = $ADODB_FETCH_MODE; - $ADODB_FETCH_MODE = ADODB_FETCH_NUM; - if ($this->fetchMode !== FALSE) { - $savem = $this->SetFetchMode(FALSE); - } - - // get index details - $rs = $this->Execute(sprintf('SHOW INDEX FROM %s',$table)); - - // restore fetchmode - if (isset($savem)) { - $this->SetFetchMode($savem); - } - $ADODB_FETCH_MODE = $save; - - if (!is_object($rs)) { - return $false; - } - - $indexes = array (); - - // parse index data into array - while ($row = $rs->FetchRow()) { - if ($primary == FALSE AND $row[2] == 'PRIMARY') { - continue; - } - - if (!isset($indexes[$row[2]])) { - $indexes[$row[2]] = array( - 'unique' => ($row[1] == 0), - 'columns' => array() - ); - } - - $indexes[$row[2]]['columns'][$row[3] - 1] = $row[4]; - } - - // sort columns by order in the index - foreach ( array_keys ($indexes) as $index ) - { - ksort ($indexes[$index]['columns']); - } - - return $indexes; - } - - - // if magic quotes disabled, use mysql_real_escape_string() - function qstr($s,$magic_quotes=false) - { - if (!$magic_quotes) { - - if (ADODB_PHPVER >= 0x4300) { - if (is_resource($this->_connectionID)) - return "'".mysql_real_escape_string($s,$this->_connectionID)."'"; - } - if ($this->replaceQuote[0] == '\\'){ - $s = adodb_str_replace(array('\\',"\0"),array('\\\\',"\\\0"),$s); - } - return "'".str_replace("'",$this->replaceQuote,$s)."'"; - } - - // undo magic quotes for " - $s = str_replace('\\"','"',$s); - return "'$s'"; - } - - function _insertid() - { - return ADOConnection::GetOne('SELECT LAST_INSERT_ID()'); - //return mysql_insert_id($this->_connectionID); - } - - function GetOne($sql,$inputarr=false) - { - if ($this->compat323 == false && strncasecmp($sql,'sele',4) == 0) { - $rs =& $this->SelectLimit($sql,1,-1,$inputarr); - if ($rs) { - $rs->Close(); - if ($rs->EOF) return false; - return reset($rs->fields); - } - } else { - return ADOConnection::GetOne($sql,$inputarr); - } - return false; - } - - function BeginTrans() - { - if ($this->debug) ADOConnection::outp("Transactions not supported in 'mysql' driver. Use 'mysqlt' or 'mysqli' driver"); - } - - function _affectedrows() - { - return mysql_affected_rows($this->_connectionID); - } - - // See http://www.mysql.com/doc/M/i/Miscellaneous_functions.html - // Reference on Last_Insert_ID on the recommended way to simulate sequences - var $_genIDSQL = "update %s set id=LAST_INSERT_ID(id+1);"; - var $_genSeqSQL = "create table %s (id int not null)"; - var $_genSeq2SQL = "insert into %s values (%s)"; - var $_dropSeqSQL = "drop table %s"; - - function CreateSequence($seqname='adodbseq',$startID=1) - { - if (empty($this->_genSeqSQL)) return false; - $u = strtoupper($seqname); - - $ok = $this->Execute(sprintf($this->_genSeqSQL,$seqname)); - if (!$ok) return false; - return $this->Execute(sprintf($this->_genSeq2SQL,$seqname,$startID-1)); - } - - - function GenID($seqname='adodbseq',$startID=1) - { - // post-nuke sets hasGenID to false - if (!$this->hasGenID) return false; - - $savelog = $this->_logsql; - $this->_logsql = false; - $getnext = sprintf($this->_genIDSQL,$seqname); - $holdtransOK = $this->_transOK; // save the current status - $rs = @$this->Execute($getnext); - if (!$rs) { - if ($holdtransOK) $this->_transOK = true; //if the status was ok before reset - $u = strtoupper($seqname); - $this->Execute(sprintf($this->_genSeqSQL,$seqname)); - $this->Execute(sprintf($this->_genSeq2SQL,$seqname,$startID-1)); - $rs = $this->Execute($getnext); - } - $this->genID = mysql_insert_id($this->_connectionID); - - if ($rs) $rs->Close(); - - $this->_logsql = $savelog; - return $this->genID; - } - - function &MetaDatabases() - { - $qid = mysql_list_dbs($this->_connectionID); - $arr = array(); - $i = 0; - $max = mysql_num_rows($qid); - while ($i < $max) { - $db = mysql_tablename($qid,$i); - if ($db != 'mysql') $arr[] = $db; - $i += 1; - } - return $arr; - } - - - // Format date column in sql string given an input format that understands Y M D - function SQLDate($fmt, $col=false) - { - if (!$col) $col = $this->sysTimeStamp; - $s = 'DATE_FORMAT('.$col.",'"; - $concat = false; - $len = strlen($fmt); - for ($i=0; $i < $len; $i++) { - $ch = $fmt[$i]; - switch($ch) { - - default: - if ($ch == '\\') { - $i++; - $ch = substr($fmt,$i,1); - } - /** FALL THROUGH */ - case '-': - case '/': - $s .= $ch; - break; - - case 'Y': - case 'y': - $s .= '%Y'; - break; - case 'M': - $s .= '%b'; - break; - - case 'm': - $s .= '%m'; - break; - case 'D': - case 'd': - $s .= '%d'; - break; - - case 'Q': - case 'q': - $s .= "'),Quarter($col)"; - - if ($len > $i+1) $s .= ",DATE_FORMAT($col,'"; - else $s .= ",('"; - $concat = true; - break; - - case 'H': - $s .= '%H'; - break; - - case 'h': - $s .= '%I'; - break; - - case 'i': - $s .= '%i'; - break; - - case 's': - $s .= '%s'; - break; - - case 'a': - case 'A': - $s .= '%p'; - break; - - case 'w': - $s .= '%w'; - break; - - case 'W': - $s .= '%U'; - break; - - case 'l': - $s .= '%W'; - break; - } - } - $s.="')"; - if ($concat) $s = "CONCAT($s)"; - return $s; - } - - - // returns concatenated string - // much easier to run "mysqld --ansi" or "mysqld --sql-mode=PIPES_AS_CONCAT" and use || operator - function Concat() - { - $s = ""; - $arr = func_get_args(); - - // suggestion by andrew005@mnogo.ru - $s = implode(',',$arr); - if (strlen($s) > 0) return "CONCAT($s)"; - else return ''; - } - - function OffsetDate($dayFraction,$date=false) - { - if (!$date) $date = $this->sysDate; - $fraction = $dayFraction * 24 * 3600; - return "from_unixtime(unix_timestamp($date)+$fraction)"; - } - - // returns true or false - function _connect($argHostname, $argUsername, $argPassword, $argDatabasename) - { - if (!empty($this->port)) $argHostname .= ":".$this->port; - - if (ADODB_PHPVER >= 0x4300) - $this->_connectionID = mysql_connect($argHostname,$argUsername,$argPassword, - $this->forceNewConnect,$this->clientFlags); - else if (ADODB_PHPVER >= 0x4200) - $this->_connectionID = mysql_connect($argHostname,$argUsername,$argPassword, - $this->forceNewConnect); - else - $this->_connectionID = mysql_connect($argHostname,$argUsername,$argPassword); - - if ($this->_connectionID === false) return false; - if ($argDatabasename) return $this->SelectDB($argDatabasename); - return true; - } - - // returns true or false - function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename) - { - if (!empty($this->port)) $argHostname .= ":".$this->port; - - if (ADODB_PHPVER >= 0x4300) - $this->_connectionID = mysql_pconnect($argHostname,$argUsername,$argPassword,$this->clientFlags); - else - $this->_connectionID = mysql_pconnect($argHostname,$argUsername,$argPassword); - if ($this->_connectionID === false) return false; - if ($this->autoRollback) $this->RollbackTrans(); - if ($argDatabasename) return $this->SelectDB($argDatabasename); - return true; - } - - function _nconnect($argHostname, $argUsername, $argPassword, $argDatabasename) - { - $this->forceNewConnect = true; - return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename); - } - - function &MetaColumns($table) - { - $this->_findschema($table,$schema); - if ($schema) { - $dbName = $this->database; - $this->SelectDB($schema); - } - global $ADODB_FETCH_MODE; - $save = $ADODB_FETCH_MODE; - $ADODB_FETCH_MODE = ADODB_FETCH_NUM; - - if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false); - $rs = $this->Execute(sprintf($this->metaColumnsSQL,$table)); - - if ($schema) { - $this->SelectDB($dbName); - } - - if (isset($savem)) $this->SetFetchMode($savem); - $ADODB_FETCH_MODE = $save; - if (!is_object($rs)) { - $false = false; - return $false; - } - - $retarr = array(); - while (!$rs->EOF){ - $fld = new ADOFieldObject(); - $fld->name = $rs->fields[0]; - $type = $rs->fields[1]; - - // split type into type(length): - $fld->scale = null; - if (preg_match("/^(.+)\((\d+),(\d+)/", $type, $query_array)) { - $fld->type = $query_array[1]; - $fld->max_length = is_numeric($query_array[2]) ? $query_array[2] : -1; - $fld->scale = is_numeric($query_array[3]) ? $query_array[3] : -1; - } elseif (preg_match("/^(.+)\((\d+)/", $type, $query_array)) { - $fld->type = $query_array[1]; - $fld->max_length = is_numeric($query_array[2]) ? $query_array[2] : -1; - } elseif (preg_match("/^(enum)\((.*)\)$/i", $type, $query_array)) { - $fld->type = $query_array[1]; - $arr = explode(",",$query_array[2]); - $fld->enums = $arr; - $zlen = max(array_map("strlen",$arr)) - 2; // PHP >= 4.0.6 - $fld->max_length = ($zlen > 0) ? $zlen : 1; - } else { - $fld->type = $type; - $fld->max_length = -1; - } - $fld->not_null = ($rs->fields[2] != 'YES'); - $fld->primary_key = ($rs->fields[3] == 'PRI'); - $fld->auto_increment = (strpos($rs->fields[5], 'auto_increment') !== false); - $fld->binary = (strpos($type,'blob') !== false); - $fld->unsigned = (strpos($type,'unsigned') !== false); - - if (!$fld->binary) { - $d = $rs->fields[4]; - if ($d != '' && $d != 'NULL') { - $fld->has_default = true; - $fld->default_value = $d; - } else { - $fld->has_default = false; - } - } - - if ($save == ADODB_FETCH_NUM) { - $retarr[] = $fld; - } else { - $retarr[strtoupper($fld->name)] = $fld; - } - $rs->MoveNext(); - } - - $rs->Close(); - return $retarr; - } - - // returns true or false - function SelectDB($dbName) - { - $this->database = $dbName; - $this->databaseName = $dbName; # obsolete, retained for compat with older adodb versions - if ($this->_connectionID) { - return @mysql_select_db($dbName,$this->_connectionID); - } - else return false; - } - - // parameters use PostgreSQL convention, not MySQL - function &SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs=0) - { - $offsetStr =($offset>=0) ? ((integer)$offset)."," : ''; - // jason judge, see http://phplens.com/lens/lensforum/msgs.php?id=9220 - if ($nrows < 0) $nrows = '18446744073709551615'; - - if ($secs) - $rs =& $this->CacheExecute($secs,$sql." LIMIT $offsetStr".((integer)$nrows),$inputarr); - else - $rs =& $this->Execute($sql." LIMIT $offsetStr".((integer)$nrows),$inputarr); - return $rs; - } - - // returns queryID or false - function _query($sql,$inputarr) - { - //global $ADODB_COUNTRECS; - //if($ADODB_COUNTRECS) - return mysql_query($sql,$this->_connectionID); - //else return @mysql_unbuffered_query($sql,$this->_connectionID); // requires PHP >= 4.0.6 - } - - /* Returns: the last error message from previous database operation */ - function ErrorMsg() - { - - if ($this->_logsql) return $this->_errorMsg; - if (empty($this->_connectionID)) $this->_errorMsg = @mysql_error(); - else $this->_errorMsg = @mysql_error($this->_connectionID); - return $this->_errorMsg; - } - - /* Returns: the last error number from previous database operation */ - function ErrorNo() - { - if ($this->_logsql) return $this->_errorCode; - if (empty($this->_connectionID)) return @mysql_errno(); - else return @mysql_errno($this->_connectionID); - } - - // returns true or false - function _close() - { - @mysql_close($this->_connectionID); - $this->_connectionID = false; - } - - - /* - * Maximum size of C field - */ - function CharMax() - { - return 255; - } - - /* - * Maximum size of X field - */ - function TextMax() - { - return 4294967295; - } - - // "Innox - Juan Carlos Gonzalez" <jgonzalez#innox.com.mx> - function MetaForeignKeys( $table, $owner = FALSE, $upper = FALSE, $associative = FALSE ) - { - if ( !empty($owner) ) { - $table = "$owner.$table"; - } - $a_create_table = $this->getRow(sprintf('SHOW CREATE TABLE %s', $table)); - if ($associative) $create_sql = $a_create_table["Create Table"]; - else $create_sql = $a_create_table[1]; - - $matches = array(); - - if (!preg_match_all("/FOREIGN KEY \(`(.*?)`\) REFERENCES `(.*?)` \(`(.*?)`\)/", $create_sql, $matches)) return false; - $foreign_keys = array(); - $num_keys = count($matches[0]); - for ( $i = 0; $i < $num_keys; $i ++ ) { - $my_field = explode('`, `', $matches[1][$i]); - $ref_table = $matches[2][$i]; - $ref_field = explode('`, `', $matches[3][$i]); - - if ( $upper ) { - $ref_table = strtoupper($ref_table); - } - - $foreign_keys[$ref_table] = array(); - $num_fields = count($my_field); - for ( $j = 0; $j < $num_fields; $j ++ ) { - if ( $associative ) { - $foreign_keys[$ref_table][$ref_field[$j]] = $my_field[$j]; - } else { - $foreign_keys[$ref_table][] = "{$my_field[$j]}={$ref_field[$j]}"; - } - } - } - - return $foreign_keys; - } - - -} - -/*-------------------------------------------------------------------------------------- - Class Name: Recordset ---------------------------------------------------------------------------------------*/ - - -class ADORecordSet_mysql extends ADORecordSet{ - - var $databaseType = "mysql"; - var $canSeek = true; - - function ADORecordSet_mysql($queryID,$mode=false) - { - if ($mode === false) { - global $ADODB_FETCH_MODE; - $mode = $ADODB_FETCH_MODE; - } - switch ($mode) - { - case ADODB_FETCH_NUM: $this->fetchMode = MYSQL_NUM; break; - case ADODB_FETCH_ASSOC:$this->fetchMode = MYSQL_ASSOC; break; - case ADODB_FETCH_DEFAULT: - case ADODB_FETCH_BOTH: - default: - $this->fetchMode = MYSQL_BOTH; break; - } - $this->adodbFetchMode = $mode; - $this->ADORecordSet($queryID); - } - - function _initrs() - { - //GLOBAL $ADODB_COUNTRECS; - // $this->_numOfRows = ($ADODB_COUNTRECS) ? @mysql_num_rows($this->_queryID):-1; - $this->_numOfRows = @mysql_num_rows($this->_queryID); - $this->_numOfFields = @mysql_num_fields($this->_queryID); - } - - function &FetchField($fieldOffset = -1) - { - if ($fieldOffset != -1) { - $o = @mysql_fetch_field($this->_queryID, $fieldOffset); - $f = @mysql_field_flags($this->_queryID,$fieldOffset); - $o->max_length = @mysql_field_len($this->_queryID,$fieldOffset); // suggested by: Jim Nicholson (jnich@att.com) - //$o->max_length = -1; // mysql returns the max length less spaces -- so it is unrealiable - $o->binary = (strpos($f,'binary')!== false); - } - else if ($fieldOffset == -1) { /* The $fieldOffset argument is not provided thus its -1 */ - $o = @mysql_fetch_field($this->_queryID); - $o->max_length = @mysql_field_len($this->_queryID); // suggested by: Jim Nicholson (jnich@att.com) - //$o->max_length = -1; // mysql returns the max length less spaces -- so it is unrealiable - } - - return $o; - } - - function &GetRowAssoc($upper=true) - { - if ($this->fetchMode == MYSQL_ASSOC && !$upper) $row = $this->fields; - else $row =& ADORecordSet::GetRowAssoc($upper); - return $row; - } - - /* Use associative array to get fields array */ - function Fields($colname) - { - // added @ by "Michael William Miller" <mille562@pilot.msu.edu> - if ($this->fetchMode != MYSQL_NUM) return @$this->fields[$colname]; - - if (!$this->bind) { - $this->bind = array(); - for ($i=0; $i < $this->_numOfFields; $i++) { - $o = $this->FetchField($i); - $this->bind[strtoupper($o->name)] = $i; - } - } - return $this->fields[$this->bind[strtoupper($colname)]]; - } - - function _seek($row) - { - if ($this->_numOfRows == 0) return false; - return @mysql_data_seek($this->_queryID,$row); - } - - function MoveNext() - { - //return adodb_movenext($this); - //if (defined('ADODB_EXTENSION')) return adodb_movenext($this); - if (@$this->fields = mysql_fetch_array($this->_queryID,$this->fetchMode)) { - $this->_currentRow += 1; - return true; - } - if (!$this->EOF) { - $this->_currentRow += 1; - $this->EOF = true; - } - return false; - } - - function _fetch() - { - $this->fields = @mysql_fetch_array($this->_queryID,$this->fetchMode); - return is_array($this->fields); - } - - function _close() { - @mysql_free_result($this->_queryID); - $this->_queryID = false; - } - - function MetaType($t,$len=-1,$fieldobj=false) - { - if (is_object($t)) { - $fieldobj = $t; - $t = $fieldobj->type; - $len = $fieldobj->max_length; - } - - $len = -1; // mysql max_length is not accurate - switch (strtoupper($t)) { - case 'STRING': - case 'CHAR': - case 'VARCHAR': - case 'TINYBLOB': - case 'TINYTEXT': - case 'ENUM': - case 'SET': - if ($len <= $this->blobSize) return 'C'; - - case 'TEXT': - case 'LONGTEXT': - case 'MEDIUMTEXT': - return 'X'; - - // php_mysql extension always returns 'blob' even if 'text' - // so we have to check whether binary... - case 'IMAGE': - case 'LONGBLOB': - case 'BLOB': - case 'MEDIUMBLOB': - return !empty($fieldobj->binary) ? 'B' : 'X'; - - case 'YEAR': - case 'DATE': return 'D'; - - case 'TIME': - case 'DATETIME': - case 'TIMESTAMP': return 'T'; - - case 'INT': - case 'INTEGER': - case 'BIGINT': - case 'TINYINT': - case 'MEDIUMINT': - case 'SMALLINT': - - if (!empty($fieldobj->primary_key)) return 'R'; - else return 'I'; - - default: return 'N'; - } - } - -} - -class ADORecordSet_ext_mysql extends ADORecordSet_mysql { - function ADORecordSet_ext_mysql($queryID,$mode=false) - { - if ($mode === false) { - global $ADODB_FETCH_MODE; - $mode = $ADODB_FETCH_MODE; - } - switch ($mode) - { - case ADODB_FETCH_NUM: $this->fetchMode = MYSQL_NUM; break; - case ADODB_FETCH_ASSOC:$this->fetchMode = MYSQL_ASSOC; break; - case ADODB_FETCH_DEFAULT: - case ADODB_FETCH_BOTH: - default: - $this->fetchMode = MYSQL_BOTH; break; - } - $this->adodbFetchMode = $mode; - $this->ADORecordSet($queryID); - } - - function MoveNext() - { - return @adodb_movenext($this); - } -} - - -} -?>
\ No newline at end of file diff --git a/framework/3rdParty/adodb/drivers/adodb-mysqli.inc.php b/framework/3rdParty/adodb/drivers/adodb-mysqli.inc.php deleted file mode 100644 index a6b0602f..00000000 --- a/framework/3rdParty/adodb/drivers/adodb-mysqli.inc.php +++ /dev/null @@ -1,986 +0,0 @@ -<?php -/* -V4.81 3 May 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved. - Released under both BSD license and Lesser GPL library license. - Whenever there is any discrepancy between the two licenses, - the BSD license will take precedence. - Set tabs to 8. - - MySQL code that does not support transactions. Use mysqlt if you need transactions. - Requires mysql client. Works on Windows and Unix. - -21 October 2003: MySQLi extension implementation by Arjen de Rijke (a.de.rijke@xs4all.nl) -Based on adodb 3.40 -*/ - -// security - hide paths -//if (!defined('ADODB_DIR')) die(); - -if (! defined("_ADODB_MYSQLI_LAYER")) { - define("_ADODB_MYSQLI_LAYER", 1 ); - - // PHP5 compat... - if (! defined("MYSQLI_BINARY_FLAG")) define("MYSQLI_BINARY_FLAG", 128); - if (!defined('MYSQLI_READ_DEFAULT_GROUP')) define('MYSQLI_READ_DEFAULT_GROUP',1); - - // disable adodb extension - currently incompatible. - global $ADODB_EXTENSION; $ADODB_EXTENSION = false; - -class ADODB_mysqli extends ADOConnection { - var $databaseType = 'mysqli'; - var $dataProvider = 'native'; - var $hasInsertID = true; - var $hasAffectedRows = true; - var $metaTablesSQL = "SHOW TABLES"; - var $metaColumnsSQL = "SHOW COLUMNS FROM %s"; - var $fmtTimeStamp = "'Y-m-d H:i:s'"; - var $hasLimit = true; - var $hasMoveFirst = true; - var $hasGenID = true; - var $isoDates = true; // accepts dates in ISO format - var $sysDate = 'CURDATE()'; - var $sysTimeStamp = 'NOW()'; - var $hasTransactions = true; - var $forceNewConnect = false; - var $poorAffectedRows = true; - var $clientFlags = 0; - var $substr = "substring"; - var $port = false; - var $socket = false; - var $_bindInputArray = false; - var $nameQuote = '`'; /// string to use to quote identifiers and names - var $optionFlags = array(array(MYSQLI_READ_DEFAULT_GROUP,0)); - - function ADODB_mysqli() - { - // if(!extension_loaded("mysqli")) - ;//trigger_error("You must have the mysqli extension installed.", E_USER_ERROR); - - } - - - // returns true or false - // To add: parameter int $port, - // parameter string $socket - function _connect($argHostname = NULL, - $argUsername = NULL, - $argPassword = NULL, - $argDatabasename = NULL, $persist=false) - { - if(!extension_loaded("mysqli")) { - return null; - } - $this->_connectionID = @mysqli_init(); - - if (is_null($this->_connectionID)) { - // mysqli_init only fails if insufficient memory - if ($this->debug) - ADOConnection::outp("mysqli_init() failed : " . $this->ErrorMsg()); - return false; - } - /* - I suggest a simple fix which would enable adodb and mysqli driver to - read connection options from the standard mysql configuration file - /etc/my.cnf - "Bastien Duclaux" <bduclaux#yahoo.com> - */ - foreach($this->optionFlags as $arr) { - mysqli_options($this->_connectionID,$arr[0],$arr[1]); - } - - #if (!empty($this->port)) $argHostname .= ":".$this->port; - $ok = mysqli_real_connect($this->_connectionID, - $argHostname, - $argUsername, - $argPassword, - $argDatabasename, - $this->port, - $this->socket, - $this->clientFlags); - - if ($ok) { - if ($argDatabasename) return $this->SelectDB($argDatabasename); - return true; - } else { - if ($this->debug) - ADOConnection::outp("Could't connect : " . $this->ErrorMsg()); - return false; - } - } - - // returns true or false - // How to force a persistent connection - function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename) - { - return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename, true); - - } - - // When is this used? Close old connection first? - // In _connect(), check $this->forceNewConnect? - function _nconnect($argHostname, $argUsername, $argPassword, $argDatabasename) - { - $this->forceNewConnect = true; - return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename); - } - - function IfNull( $field, $ifNull ) - { - return " IFNULL($field, $ifNull) "; // if MySQL - } - - function ServerInfo() - { - $arr['description'] = $this->GetOne("select version()"); - $arr['version'] = ADOConnection::_findvers($arr['description']); - return $arr; - } - - - function BeginTrans() - { - if ($this->transOff) return true; - $this->transCnt += 1; - $this->Execute('SET AUTOCOMMIT=0'); - $this->Execute('BEGIN'); - return true; - } - - function CommitTrans($ok=true) - { - if ($this->transOff) return true; - if (!$ok) return $this->RollbackTrans(); - - if ($this->transCnt) $this->transCnt -= 1; - $this->Execute('COMMIT'); - $this->Execute('SET AUTOCOMMIT=1'); - return true; - } - - function RollbackTrans() - { - if ($this->transOff) return true; - if ($this->transCnt) $this->transCnt -= 1; - $this->Execute('ROLLBACK'); - $this->Execute('SET AUTOCOMMIT=1'); - return true; - } - - function RowLock($tables,$where='',$flds='1 as adodb_ignore') - { - if ($this->transCnt==0) $this->BeginTrans(); - if ($where) $where = ' where '.$where; - $rs =& $this->Execute("select $flds from $tables $where for update"); - return !empty($rs); - } - - // if magic quotes disabled, use mysql_real_escape_string() - // From readme.htm: - // Quotes a string to be sent to the database. The $magic_quotes_enabled - // parameter may look funny, but the idea is if you are quoting a - // string extracted from a POST/GET variable, then - // pass get_magic_quotes_gpc() as the second parameter. This will - // ensure that the variable is not quoted twice, once by qstr and once - // by the magic_quotes_gpc. - // - //Eg. $s = $db->qstr(_GET['name'],get_magic_quotes_gpc()); - function qstr($s, $magic_quotes = false) - { - if (!$magic_quotes) { - if (PHP_VERSION >= 5) - return "'" . mysqli_real_escape_string($this->_connectionID, $s) . "'"; - - if ($this->replaceQuote[0] == '\\') - $s = adodb_str_replace(array('\\',"\0"),array('\\\\',"\\\0"),$s); - return "'".str_replace("'",$this->replaceQuote,$s)."'"; - } - // undo magic quotes for " - $s = str_replace('\\"','"',$s); - return "'$s'"; - } - - function _insertid() - { - $result = @mysqli_insert_id($this->_connectionID); - if ($result == -1){ - if ($this->debug) ADOConnection::outp("mysqli_insert_id() failed : " . $this->ErrorMsg()); - } - return $result; - } - - // Only works for INSERT, UPDATE and DELETE query's - function _affectedrows() - { - $result = @mysqli_affected_rows($this->_connectionID); - if ($result == -1) { - if ($this->debug) ADOConnection::outp("mysqli_affected_rows() failed : " . $this->ErrorMsg()); - } - return $result; - } - - // See http://www.mysql.com/doc/M/i/Miscellaneous_functions.html - // Reference on Last_Insert_ID on the recommended way to simulate sequences - var $_genIDSQL = "update %s set id=LAST_INSERT_ID(id+1);"; - var $_genSeqSQL = "create table %s (id int not null)"; - var $_genSeq2SQL = "insert into %s values (%s)"; - var $_dropSeqSQL = "drop table %s"; - - function CreateSequence($seqname='adodbseq',$startID=1) - { - if (empty($this->_genSeqSQL)) return false; - $u = strtoupper($seqname); - - $ok = $this->Execute(sprintf($this->_genSeqSQL,$seqname)); - if (!$ok) return false; - return $this->Execute(sprintf($this->_genSeq2SQL,$seqname,$startID-1)); - } - - function GenID($seqname='adodbseq',$startID=1) - { - // post-nuke sets hasGenID to false - if (!$this->hasGenID) return false; - - $getnext = sprintf($this->_genIDSQL,$seqname); - $holdtransOK = $this->_transOK; // save the current status - $rs = @$this->Execute($getnext); - if (!$rs) { - if ($holdtransOK) $this->_transOK = true; //if the status was ok before reset - $u = strtoupper($seqname); - $this->Execute(sprintf($this->_genSeqSQL,$seqname)); - $this->Execute(sprintf($this->_genSeq2SQL,$seqname,$startID-1)); - $rs = $this->Execute($getnext); - } - $this->genID = mysqli_insert_id($this->_connectionID); - - if ($rs) $rs->Close(); - - return $this->genID; - } - - function &MetaDatabases() - { - $query = "SHOW DATABASES"; - $ret =& $this->Execute($query); - if ($ret && is_object($ret)){ - $arr = array(); - while (!$ret->EOF){ - $db = $ret->Fields('Database'); - if ($db != 'mysql') $arr[] = $db; - $ret->MoveNext(); - } - return $arr; - } - return $ret; - } - - - function &MetaIndexes ($table, $primary = FALSE) - { - // save old fetch mode - global $ADODB_FETCH_MODE; - - $false = false; - $save = $ADODB_FETCH_MODE; - $ADODB_FETCH_MODE = ADODB_FETCH_NUM; - if ($this->fetchMode !== FALSE) { - $savem = $this->SetFetchMode(FALSE); - } - - // get index details - $rs = $this->Execute(sprintf('SHOW INDEXES FROM %s',$table)); - - // restore fetchmode - if (isset($savem)) { - $this->SetFetchMode($savem); - } - $ADODB_FETCH_MODE = $save; - - if (!is_object($rs)) { - return $false; - } - - $indexes = array (); - - // parse index data into array - while ($row = $rs->FetchRow()) { - if ($primary == FALSE AND $row[2] == 'PRIMARY') { - continue; - } - - if (!isset($indexes[$row[2]])) { - $indexes[$row[2]] = array( - 'unique' => ($row[1] == 0), - 'columns' => array() - ); - } - - $indexes[$row[2]]['columns'][$row[3] - 1] = $row[4]; - } - - // sort columns by order in the index - foreach ( array_keys ($indexes) as $index ) - { - ksort ($indexes[$index]['columns']); - } - - return $indexes; - } - - - // Format date column in sql string given an input format that understands Y M D - function SQLDate($fmt, $col=false) - { - if (!$col) $col = $this->sysTimeStamp; - $s = 'DATE_FORMAT('.$col.",'"; - $concat = false; - $len = strlen($fmt); - for ($i=0; $i < $len; $i++) { - $ch = $fmt[$i]; - switch($ch) { - case 'Y': - case 'y': - $s .= '%Y'; - break; - case 'Q': - case 'q': - $s .= "'),Quarter($col)"; - - if ($len > $i+1) $s .= ",DATE_FORMAT($col,'"; - else $s .= ",('"; - $concat = true; - break; - case 'M': - $s .= '%b'; - break; - - case 'm': - $s .= '%m'; - break; - case 'D': - case 'd': - $s .= '%d'; - break; - - case 'H': - $s .= '%H'; - break; - - case 'h': - $s .= '%I'; - break; - - case 'i': - $s .= '%i'; - break; - - case 's': - $s .= '%s'; - break; - - case 'a': - case 'A': - $s .= '%p'; - break; - - case 'w': - $s .= '%w'; - break; - - case 'l': - $s .= '%W'; - break; - - default: - - if ($ch == '\\') { - $i++; - $ch = substr($fmt,$i,1); - } - $s .= $ch; - break; - } - } - $s.="')"; - if ($concat) $s = "CONCAT($s)"; - return $s; - } - - // returns concatenated string - // much easier to run "mysqld --ansi" or "mysqld --sql-mode=PIPES_AS_CONCAT" and use || operator - function Concat() - { - $s = ""; - $arr = func_get_args(); - - // suggestion by andrew005@mnogo.ru - $s = implode(',',$arr); - if (strlen($s) > 0) return "CONCAT($s)"; - else return ''; - } - - // dayFraction is a day in floating point - function OffsetDate($dayFraction,$date=false) - { - if (!$date) - $date = $this->sysDate; - return "from_unixtime(unix_timestamp($date)+($dayFraction)*24*3600)"; - } - - function &MetaTables($ttype=false,$showSchema=false,$mask=false) - { - $save = $this->metaTablesSQL; - if ($showSchema && is_string($showSchema)) { - $this->metaTablesSQL .= " from $showSchema"; - } - - if ($mask) { - $mask = $this->qstr($mask); - $this->metaTablesSQL .= " like $mask"; - } - $ret =& ADOConnection::MetaTables($ttype,$showSchema); - - $this->metaTablesSQL = $save; - return $ret; - } - - // "Innox - Juan Carlos Gonzalez" <jgonzalez#innox.com.mx> - function MetaForeignKeys( $table, $owner = FALSE, $upper = FALSE, $associative = FALSE ) - { - if ( !empty($owner) ) { - $table = "$owner.$table"; - } - $a_create_table = $this->getRow(sprintf('SHOW CREATE TABLE %s', $table)); - if ($associative) $create_sql = $a_create_table["Create Table"]; - else $create_sql = $a_create_table[1]; - - $matches = array(); - - if (!preg_match_all("/FOREIGN KEY \(`(.*?)`\) REFERENCES `(.*?)` \(`(.*?)`\)/", $create_sql, $matches)) return false; - $foreign_keys = array(); - $num_keys = count($matches[0]); - for ( $i = 0; $i < $num_keys; $i ++ ) { - $my_field = explode('`, `', $matches[1][$i]); - $ref_table = $matches[2][$i]; - $ref_field = explode('`, `', $matches[3][$i]); - - if ( $upper ) { - $ref_table = strtoupper($ref_table); - } - - $foreign_keys[$ref_table] = array(); - $num_fields = count($my_field); - for ( $j = 0; $j < $num_fields; $j ++ ) { - if ( $associative ) { - $foreign_keys[$ref_table][$ref_field[$j]] = $my_field[$j]; - } else { - $foreign_keys[$ref_table][] = "{$my_field[$j]}={$ref_field[$j]}"; - } - } - } - - return $foreign_keys; - } - - function &MetaColumns($table) - { - $false = false; - if (!$this->metaColumnsSQL) - return $false; - - global $ADODB_FETCH_MODE; - $save = $ADODB_FETCH_MODE; - $ADODB_FETCH_MODE = ADODB_FETCH_NUM; - if ($this->fetchMode !== false) - $savem = $this->SetFetchMode(false); - $rs = $this->Execute(sprintf($this->metaColumnsSQL,$table)); - if (isset($savem)) $this->SetFetchMode($savem); - $ADODB_FETCH_MODE = $save; - if (!is_object($rs)) - return $false; - - $retarr = array(); - while (!$rs->EOF) { - $fld = new ADOFieldObject(); - $fld->name = $rs->fields[0]; - $type = $rs->fields[1]; - - // split type into type(length): - $fld->scale = null; - if (preg_match("/^(.+)\((\d+),(\d+)/", $type, $query_array)) { - $fld->type = $query_array[1]; - $fld->max_length = is_numeric($query_array[2]) ? $query_array[2] : -1; - $fld->scale = is_numeric($query_array[3]) ? $query_array[3] : -1; - } elseif (preg_match("/^(.+)\((\d+)/", $type, $query_array)) { - $fld->type = $query_array[1]; - $fld->max_length = is_numeric($query_array[2]) ? $query_array[2] : -1; - } elseif (preg_match("/^(enum)\((.*)\)$/i", $type, $query_array)) { - $fld->type = $query_array[1]; - $fld->max_length = max(array_map("strlen",explode(",",$query_array[2]))) - 2; // PHP >= 4.0.6 - $fld->max_length = ($fld->max_length == 0 ? 1 : $fld->max_length); - } else { - $fld->type = $type; - $fld->max_length = -1; - } - $fld->not_null = ($rs->fields[2] != 'YES'); - $fld->primary_key = ($rs->fields[3] == 'PRI'); - $fld->auto_increment = (strpos($rs->fields[5], 'auto_increment') !== false); - $fld->binary = (strpos($type,'blob') !== false); - $fld->unsigned = (strpos($type,'unsigned') !== false); - - if (!$fld->binary) { - $d = $rs->fields[4]; - if ($d != '' && $d != 'NULL') { - $fld->has_default = true; - $fld->default_value = $d; - } else { - $fld->has_default = false; - } - } - - if ($save == ADODB_FETCH_NUM) { - $retarr[] = $fld; - } else { - $retarr[strtoupper($fld->name)] = $fld; - } - $rs->MoveNext(); - } - - $rs->Close(); - return $retarr; - } - - // returns true or false - function SelectDB($dbName) - { -// $this->_connectionID = $this->mysqli_resolve_link($this->_connectionID); - $this->database = $dbName; - $this->databaseName = $dbName; # obsolete, retained for compat with older adodb versions - - if ($this->_connectionID) { - $result = @mysqli_select_db($this->_connectionID, $dbName); - if (!$result) { - ADOConnection::outp("Select of database " . $dbName . " failed. " . $this->ErrorMsg()); - } - return $result; - } - return false; - } - - // parameters use PostgreSQL convention, not MySQL - function &SelectLimit($sql, - $nrows = -1, - $offset = -1, - $inputarr = false, - $arg3 = false, - $secs = 0) - { - $offsetStr = ($offset >= 0) ? "$offset," : ''; - if ($nrows < 0) $nrows = '18446744073709551615'; - - if ($secs) - $rs =& $this->CacheExecute($secs, $sql . " LIMIT $offsetStr$nrows" , $inputarr , $arg3); - else - $rs =& $this->Execute($sql . " LIMIT $offsetStr$nrows" , $inputarr , $arg3); - - return $rs; - } - - - function Prepare($sql) - { - return $sql; - - $stmt = $this->_connectionID->prepare($sql); - if (!$stmt) { - echo $this->ErrorMsg(); - return $sql; - } - return array($sql,$stmt); - } - - - // returns queryID or false - function _query($sql, $inputarr) - { - global $ADODB_COUNTRECS; - - if (is_array($sql)) { - $stmt = $sql[1]; - $a = ''; - foreach($inputarr as $k => $v) { - if (is_string($v)) $a .= 's'; - else if (is_integer($v)) $a .= 'i'; - else $a .= 'd'; - } - - $fnarr = array_merge( array($stmt,$a) , $inputarr); - $ret = call_user_func_array('mysqli_stmt_bind_param',$fnarr); - - $ret = mysqli_stmt_execute($stmt); - return $ret; - } - if (!$mysql_res = mysqli_query($this->_connectionID, $sql, ($ADODB_COUNTRECS) ? MYSQLI_STORE_RESULT : MYSQLI_USE_RESULT)) { - if ($this->debug) ADOConnection::outp("Query: " . $sql . " failed. " . $this->ErrorMsg()); - return false; - } - - return $mysql_res; - } - - /* Returns: the last error message from previous database operation */ - function ErrorMsg() - { - if (empty($this->_connectionID)) - $this->_errorMsg = @mysqli_connect_error(); - else - $this->_errorMsg = @mysqli_error($this->_connectionID); - return $this->_errorMsg; - } - - /* Returns: the last error number from previous database operation */ - function ErrorNo() - { - if (empty($this->_connectionID)) - return @mysqli_connect_errno(); - else - return @mysqli_errno($this->_connectionID); - } - - // returns true or false - function _close() - { - @mysqli_close($this->_connectionID); - $this->_connectionID = false; - } - - /* - * Maximum size of C field - */ - function CharMax() - { - return 255; - } - - /* - * Maximum size of X field - */ - function TextMax() - { - return 4294967295; - } - - - - // this is a set of functions for managing client encoding - very important if the encodings - // of your database and your output target (i.e. HTML) don't match - // for instance, you may have UTF8 database and server it on-site as latin1 etc. - // GetCharSet - get the name of the character set the client is using now - // Under Windows, the functions should work with MySQL 4.1.11 and above, the set of charsets supported - // depends on compile flags of mysql distribution - - function GetCharSet() - { - //we will use ADO's builtin property charSet - if (!method_exists($this->_connectionID,'character_set_name')) - return false; - - $this->charSet = @$this->_connectionID->character_set_name(); - if (!$this->charSet) { - return false; - } else { - return $this->charSet; - } - } - - // SetCharSet - switch the client encoding - function SetCharSet($charset_name) - { - if (!method_exists($this->_connectionID,'set_charset')) - return false; - - if ($this->charSet !== $charset_name) { - $if = @$this->_connectionID->set_charset($charset_name); - if ($if == "0" & $this->GetCharSet() == $charset_name) { - return true; - } else return false; - } else return true; - } - - - - -} - -/*-------------------------------------------------------------------------------------- - Class Name: Recordset ---------------------------------------------------------------------------------------*/ - -class ADORecordSet_mysqli extends ADORecordSet{ - - var $databaseType = "mysqli"; - var $canSeek = true; - - function ADORecordSet_mysqli($queryID, $mode = false) - { - if ($mode === false) - { - global $ADODB_FETCH_MODE; - $mode = $ADODB_FETCH_MODE; - } - - switch ($mode) - { - case ADODB_FETCH_NUM: - $this->fetchMode = MYSQLI_NUM; - break; - case ADODB_FETCH_ASSOC: - $this->fetchMode = MYSQLI_ASSOC; - break; - case ADODB_FETCH_DEFAULT: - case ADODB_FETCH_BOTH: - default: - $this->fetchMode = MYSQLI_BOTH; - break; - } - $this->adodbFetchMode = $mode; - $this->ADORecordSet($queryID); - } - - function _initrs() - { - global $ADODB_COUNTRECS; - - $this->_numOfRows = $ADODB_COUNTRECS ? @mysqli_num_rows($this->_queryID) : -1; - $this->_numOfFields = @mysqli_num_fields($this->_queryID); - } - -/* -1 = MYSQLI_NOT_NULL_FLAG -2 = MYSQLI_PRI_KEY_FLAG -4 = MYSQLI_UNIQUE_KEY_FLAG -8 = MYSQLI_MULTIPLE_KEY_FLAG -16 = MYSQLI_BLOB_FLAG -32 = MYSQLI_UNSIGNED_FLAG -64 = MYSQLI_ZEROFILL_FLAG -128 = MYSQLI_BINARY_FLAG -256 = MYSQLI_ENUM_FLAG -512 = MYSQLI_AUTO_INCREMENT_FLAG -1024 = MYSQLI_TIMESTAMP_FLAG -2048 = MYSQLI_SET_FLAG -32768 = MYSQLI_NUM_FLAG -16384 = MYSQLI_PART_KEY_FLAG -32768 = MYSQLI_GROUP_FLAG -65536 = MYSQLI_UNIQUE_FLAG -131072 = MYSQLI_BINCMP_FLAG -*/ - - function &FetchField($fieldOffset = -1) - { - $fieldnr = $fieldOffset; - if ($fieldOffset != -1) { - $fieldOffset = mysqli_field_seek($this->_queryID, $fieldnr); - } - $o = mysqli_fetch_field($this->_queryID); - /* Properties of an ADOFieldObject as set by MetaColumns */ - $o->primary_key = $o->flags & MYSQLI_PRI_KEY_FLAG; - $o->not_null = $o->flags & MYSQLI_NOT_NULL_FLAG; - $o->auto_increment = $o->flags & MYSQLI_AUTO_INCREMENT_FLAG; - $o->binary = $o->flags & MYSQLI_BINARY_FLAG; - // $o->blob = $o->flags & MYSQLI_BLOB_FLAG; /* not returned by MetaColumns */ - $o->unsigned = $o->flags & MYSQLI_UNSIGNED_FLAG; - - return $o; - } - - function &GetRowAssoc($upper = true) - { - if ($this->fetchMode == MYSQLI_ASSOC && !$upper) - return $this->fields; - $row =& ADORecordSet::GetRowAssoc($upper); - return $row; - } - - /* Use associative array to get fields array */ - function Fields($colname) - { - if ($this->fetchMode != MYSQLI_NUM) - return @$this->fields[$colname]; - - if (!$this->bind) { - $this->bind = array(); - for ($i = 0; $i < $this->_numOfFields; $i++) { - $o = $this->FetchField($i); - $this->bind[strtoupper($o->name)] = $i; - } - } - return $this->fields[$this->bind[strtoupper($colname)]]; - } - - function _seek($row) - { - if ($this->_numOfRows == 0) - return false; - - if ($row < 0) - return false; - - mysqli_data_seek($this->_queryID, $row); - $this->EOF = false; - return true; - } - - // 10% speedup to move MoveNext to child class - // This is the only implementation that works now (23-10-2003). - // Other functions return no or the wrong results. - function MoveNext() - { - if ($this->EOF) return false; - $this->_currentRow++; - $this->fields = @mysqli_fetch_array($this->_queryID,$this->fetchMode); - - if (is_array($this->fields)) return true; - $this->EOF = true; - return false; - } - - function _fetch() - { - $this->fields = mysqli_fetch_array($this->_queryID,$this->fetchMode); - return is_array($this->fields); - } - - function _close() - { - mysqli_free_result($this->_queryID); - $this->_queryID = false; - } - -/* - -0 = MYSQLI_TYPE_DECIMAL -1 = MYSQLI_TYPE_CHAR -1 = MYSQLI_TYPE_TINY -2 = MYSQLI_TYPE_SHORT -3 = MYSQLI_TYPE_LONG -4 = MYSQLI_TYPE_FLOAT -5 = MYSQLI_TYPE_DOUBLE -6 = MYSQLI_TYPE_NULL -7 = MYSQLI_TYPE_TIMESTAMP -8 = MYSQLI_TYPE_LONGLONG -9 = MYSQLI_TYPE_INT24 -10 = MYSQLI_TYPE_DATE -11 = MYSQLI_TYPE_TIME -12 = MYSQLI_TYPE_DATETIME -13 = MYSQLI_TYPE_YEAR -14 = MYSQLI_TYPE_NEWDATE -247 = MYSQLI_TYPE_ENUM -248 = MYSQLI_TYPE_SET -249 = MYSQLI_TYPE_TINY_BLOB -250 = MYSQLI_TYPE_MEDIUM_BLOB -251 = MYSQLI_TYPE_LONG_BLOB -252 = MYSQLI_TYPE_BLOB -253 = MYSQLI_TYPE_VAR_STRING -254 = MYSQLI_TYPE_STRING -255 = MYSQLI_TYPE_GEOMETRY -*/ - - function MetaType($t, $len = -1, $fieldobj = false) - { - if (is_object($t)) { - $fieldobj = $t; - $t = $fieldobj->type; - $len = $fieldobj->max_length; - } - - - $len = -1; // mysql max_length is not accurate - switch (strtoupper($t)) { - case 'STRING': - case 'CHAR': - case 'VARCHAR': - case 'TINYBLOB': - case 'TINYTEXT': - case 'ENUM': - case 'SET': - - case MYSQLI_TYPE_TINY_BLOB : - case MYSQLI_TYPE_CHAR : - case MYSQLI_TYPE_STRING : - case MYSQLI_TYPE_ENUM : - case MYSQLI_TYPE_SET : - case 253 : - if ($len <= $this->blobSize) return 'C'; - - case 'TEXT': - case 'LONGTEXT': - case 'MEDIUMTEXT': - return 'X'; - - - // php_mysql extension always returns 'blob' even if 'text' - // so we have to check whether binary... - case 'IMAGE': - case 'LONGBLOB': - case 'BLOB': - case 'MEDIUMBLOB': - - case MYSQLI_TYPE_BLOB : - case MYSQLI_TYPE_LONG_BLOB : - case MYSQLI_TYPE_MEDIUM_BLOB : - - return !empty($fieldobj->binary) ? 'B' : 'X'; - case 'YEAR': - case 'DATE': - case MYSQLI_TYPE_DATE : - case MYSQLI_TYPE_YEAR : - - return 'D'; - - case 'TIME': - case 'DATETIME': - case 'TIMESTAMP': - - case MYSQLI_TYPE_DATETIME : - case MYSQLI_TYPE_NEWDATE : - case MYSQLI_TYPE_TIME : - case MYSQLI_TYPE_TIMESTAMP : - - return 'T'; - - case 'INT': - case 'INTEGER': - case 'BIGINT': - case 'TINYINT': - case 'MEDIUMINT': - case 'SMALLINT': - - case MYSQLI_TYPE_INT24 : - case MYSQLI_TYPE_LONG : - case MYSQLI_TYPE_LONGLONG : - case MYSQLI_TYPE_SHORT : - case MYSQLI_TYPE_TINY : - - if (!empty($fieldobj->primary_key)) return 'R'; - - return 'I'; - - - // Added floating-point types - // Maybe not necessery. - case 'FLOAT': - case 'DOUBLE': - // case 'DOUBLE PRECISION': - case 'DECIMAL': - case 'DEC': - case 'FIXED': - default: - //if (!is_numeric($t)) echo "<p>--- Error in type matching $t -----</p>"; - return 'N'; - } - } // function - - -} // rs class - -} - -?>
\ No newline at end of file diff --git a/framework/3rdParty/adodb/drivers/adodb-mysqlt.inc.php b/framework/3rdParty/adodb/drivers/adodb-mysqlt.inc.php deleted file mode 100644 index ea62002f..00000000 --- a/framework/3rdParty/adodb/drivers/adodb-mysqlt.inc.php +++ /dev/null @@ -1,138 +0,0 @@ -<?php - -/* -V4.81 3 May 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved. - Released under both BSD license and Lesser GPL library license. - Whenever there is any discrepancy between the two licenses, - the BSD license will take precedence. - Set tabs to 8. - - MySQL code that supports transactions. For MySQL 3.23 or later. - Code from James Poon <jpoon88@yahoo.com> - - Requires mysql client. Works on Windows and Unix. -*/ - -// security - hide paths -if (!defined('ADODB_DIR')) die(); - -include_once(ADODB_DIR."/drivers/adodb-mysql.inc.php"); - - -class ADODB_mysqlt extends ADODB_mysql { - var $databaseType = 'mysqlt'; - var $ansiOuter = true; // for Version 3.23.17 or later - var $hasTransactions = true; - var $autoRollback = true; // apparently mysql does not autorollback properly - - function ADODB_mysqlt() - { - global $ADODB_EXTENSION; if ($ADODB_EXTENSION) $this->rsPrefix .= 'ext_'; - } - - function BeginTrans() - { - if ($this->transOff) return true; - $this->transCnt += 1; - $this->Execute('SET AUTOCOMMIT=0'); - $this->Execute('BEGIN'); - return true; - } - - function CommitTrans($ok=true) - { - if ($this->transOff) return true; - if (!$ok) return $this->RollbackTrans(); - - if ($this->transCnt) $this->transCnt -= 1; - $this->Execute('COMMIT'); - $this->Execute('SET AUTOCOMMIT=1'); - return true; - } - - function RollbackTrans() - { - if ($this->transOff) return true; - if ($this->transCnt) $this->transCnt -= 1; - $this->Execute('ROLLBACK'); - $this->Execute('SET AUTOCOMMIT=1'); - return true; - } - - function RowLock($tables,$where='',$flds='1 as adodb_ignore') - { - if ($this->transCnt==0) $this->BeginTrans(); - if ($where) $where = ' where '.$where; - $rs =& $this->Execute("select $flds from $tables $where for update"); - return !empty($rs); - } - -} - -class ADORecordSet_mysqlt extends ADORecordSet_mysql{ - var $databaseType = "mysqlt"; - - function ADORecordSet_mysqlt($queryID,$mode=false) - { - if ($mode === false) { - global $ADODB_FETCH_MODE; - $mode = $ADODB_FETCH_MODE; - } - - switch ($mode) - { - case ADODB_FETCH_NUM: $this->fetchMode = MYSQL_NUM; break; - case ADODB_FETCH_ASSOC:$this->fetchMode = MYSQL_ASSOC; break; - - case ADODB_FETCH_DEFAULT: - case ADODB_FETCH_BOTH: - default: $this->fetchMode = MYSQL_BOTH; break; - } - - $this->adodbFetchMode = $mode; - $this->ADORecordSet($queryID); - } - - function MoveNext() - { - if (@$this->fields = mysql_fetch_array($this->_queryID,$this->fetchMode)) { - $this->_currentRow += 1; - return true; - } - if (!$this->EOF) { - $this->_currentRow += 1; - $this->EOF = true; - } - return false; - } -} - -class ADORecordSet_ext_mysqlt extends ADORecordSet_mysqlt { - - function ADORecordSet_ext_mysqlt($queryID,$mode=false) - { - if ($mode === false) { - global $ADODB_FETCH_MODE; - $mode = $ADODB_FETCH_MODE; - } - switch ($mode) - { - case ADODB_FETCH_NUM: $this->fetchMode = MYSQL_NUM; break; - case ADODB_FETCH_ASSOC:$this->fetchMode = MYSQL_ASSOC; break; - - case ADODB_FETCH_DEFAULT: - case ADODB_FETCH_BOTH: - default: - $this->fetchMode = MYSQL_BOTH; break; - } - $this->adodbFetchMode = $mode; - $this->ADORecordSet($queryID); - } - - function MoveNext() - { - return adodb_movenext($this); - } -} - -?>
\ No newline at end of file diff --git a/framework/3rdParty/adodb/drivers/adodb-oci8.inc.php b/framework/3rdParty/adodb/drivers/adodb-oci8.inc.php deleted file mode 100644 index 48d4ce0b..00000000 --- a/framework/3rdParty/adodb/drivers/adodb-oci8.inc.php +++ /dev/null @@ -1,1484 +0,0 @@ -<?php -/* - - version V4.81 3 May 2006 (c) 2000-2006 John Lim. All rights reserved. - - Released under both BSD license and Lesser GPL library license. - Whenever there is any discrepancy between the two licenses, - the BSD license will take precedence. - - Latest version is available at http://adodb.sourceforge.net - - Code contributed by George Fourlanos <fou@infomap.gr> - - 13 Nov 2000 jlim - removed all ora_* references. -*/ - -// security - hide paths -if (!defined('ADODB_DIR')) die(); - -/* -NLS_Date_Format -Allows you to use a date format other than the Oracle Lite default. When a literal -character string appears where a date value is expected, the Oracle Lite database -tests the string to see if it matches the formats of Oracle, SQL-92, or the value -specified for this parameter in the POLITE.INI file. Setting this parameter also -defines the default format used in the TO_CHAR or TO_DATE functions when no -other format string is supplied. - -For Oracle the default is dd-mon-yy or dd-mon-yyyy, and for SQL-92 the default is -yy-mm-dd or yyyy-mm-dd. - -Using 'RR' in the format forces two-digit years less than or equal to 49 to be -interpreted as years in the 21st century (2000–2049), and years over 50 as years in -the 20th century (1950–1999). Setting the RR format as the default for all two-digit -year entries allows you to become year-2000 compliant. For example: -NLS_DATE_FORMAT='RR-MM-DD' - -You can also modify the date format using the ALTER SESSION command. -*/ - -# define the LOB descriptor type for the given type -# returns false if no LOB descriptor -function oci_lob_desc($type) { - switch ($type) { - case OCI_B_BFILE: $result = OCI_D_FILE; break; - case OCI_B_CFILEE: $result = OCI_D_FILE; break; - case OCI_B_CLOB: $result = OCI_D_LOB; break; - case OCI_B_BLOB: $result = OCI_D_LOB; break; - case OCI_B_ROWID: $result = OCI_D_ROWID; break; - default: $result = false; break; - } - return $result; -} - -class ADODB_oci8 extends ADOConnection { - var $databaseType = 'oci8'; - var $dataProvider = 'oci8'; - var $replaceQuote = "''"; // string to use to replace quotes - var $concat_operator='||'; - var $sysDate = "TRUNC(SYSDATE)"; - var $sysTimeStamp = 'SYSDATE'; - var $metaDatabasesSQL = "SELECT USERNAME FROM ALL_USERS WHERE USERNAME NOT IN ('SYS','SYSTEM','DBSNMP','OUTLN') ORDER BY 1"; - var $_stmt; - var $_commit = OCI_COMMIT_ON_SUCCESS; - var $_initdate = true; // init date to YYYY-MM-DD - var $metaTablesSQL = "select table_name,table_type from cat where table_type in ('TABLE','VIEW')"; - var $metaColumnsSQL = "select cname,coltype,width, SCALE, PRECISION, NULLS, DEFAULTVAL from col where tname='%s' order by colno"; //changed by smondino@users.sourceforge. net - var $_bindInputArray = true; - var $hasGenID = true; - var $_genIDSQL = "SELECT (%s.nextval) FROM DUAL"; - var $_genSeqSQL = "CREATE SEQUENCE %s START WITH %s"; - var $_dropSeqSQL = "DROP SEQUENCE %s"; - var $hasAffectedRows = true; - var $random = "abs(mod(DBMS_RANDOM.RANDOM,10000001)/10000000)"; - var $noNullStrings = false; - var $connectSID = false; - var $_bind = false; - var $_hasOCIFetchStatement = false; - var $_getarray = false; // currently not working - var $leftOuter = ''; // oracle wierdness, $col = $value (+) for LEFT OUTER, $col (+)= $value for RIGHT OUTER - var $session_sharing_force_blob = false; // alter session on updateblob if set to true - var $firstrows = true; // enable first rows optimization on SelectLimit() - var $selectOffsetAlg1 = 100; // when to use 1st algorithm of selectlimit. - var $NLS_DATE_FORMAT = 'YYYY-MM-DD'; // To include time, use 'RRRR-MM-DD HH24:MI:SS' - var $useDBDateFormatForTextInput=false; - var $datetime = false; // MetaType('DATE') returns 'D' (datetime==false) or 'T' (datetime == true) - var $_refLOBs = array(); - - // var $ansiOuter = true; // if oracle9 - - function ADODB_oci8() - { - $this->_hasOCIFetchStatement = ADODB_PHPVER >= 0x4200; - if (defined('ADODB_EXTENSION')) $this->rsPrefix .= 'ext_'; - } - - /* Function &MetaColumns($table) added by smondino@users.sourceforge.net*/ - function &MetaColumns($table) - { - global $ADODB_FETCH_MODE; - - $false = false; - $save = $ADODB_FETCH_MODE; - $ADODB_FETCH_MODE = ADODB_FETCH_NUM; - if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false); - - $rs = $this->Execute(sprintf($this->metaColumnsSQL,strtoupper($table))); - - if (isset($savem)) $this->SetFetchMode($savem); - $ADODB_FETCH_MODE = $save; - if (!$rs) { - return $false; - } - $retarr = array(); - while (!$rs->EOF) { //print_r($rs->fields); - $fld = new ADOFieldObject(); - $fld->name = $rs->fields[0]; - $fld->type = $rs->fields[1]; - $fld->max_length = $rs->fields[2]; - $fld->scale = $rs->fields[3]; - if ($rs->fields[1] == 'NUMBER' && $rs->fields[3] == 0) { - $fld->type ='INT'; - $fld->max_length = $rs->fields[4]; - } - $fld->not_null = (strncmp($rs->fields[5], 'NOT',3) === 0); - $fld->binary = (strpos($fld->type,'BLOB') !== false); - $fld->default_value = $rs->fields[6]; - - if ($ADODB_FETCH_MODE == ADODB_FETCH_NUM) $retarr[] = $fld; - else $retarr[strtoupper($fld->name)] = $fld; - $rs->MoveNext(); - } - $rs->Close(); - if (empty($retarr)) - return $false; - else - return $retarr; - } - - function Time() - { - $rs =& $this->Execute("select TO_CHAR($this->sysTimeStamp,'YYYY-MM-DD HH24:MI:SS') from dual"); - if ($rs && !$rs->EOF) return $this->UnixTimeStamp(reset($rs->fields)); - - return false; - } - -/* - - Multiple modes of connection are supported: - - a. Local Database - $conn->Connect(false,'scott','tiger'); - - b. From tnsnames.ora - $conn->Connect(false,'scott','tiger',$tnsname); - $conn->Connect($tnsname,'scott','tiger'); - - c. Server + service name - $conn->Connect($serveraddress,'scott,'tiger',$service_name); - - d. Server + SID - $conn->connectSID = true; - $conn->Connect($serveraddress,'scott,'tiger',$SID); - - -Example TNSName: ---------------- -NATSOFT.DOMAIN = - (DESCRIPTION = - (ADDRESS_LIST = - (ADDRESS = (PROTOCOL = TCP)(HOST = kermit)(PORT = 1523)) - ) - (CONNECT_DATA = - (SERVICE_NAME = natsoft.domain) - ) - ) - - There are 3 connection modes, 0 = non-persistent, 1 = persistent, 2 = force new connection - -*/ - function _connect($argHostname, $argUsername, $argPassword, $argDatabasename,$mode=0) - { - if (!function_exists('OCIPLogon')) return null; - - - $this->_errorMsg = false; - $this->_errorCode = false; - - if($argHostname) { // added by Jorma Tuomainen <jorma.tuomainen@ppoy.fi> - if (empty($argDatabasename)) $argDatabasename = $argHostname; - else { - if(strpos($argHostname,":")) { - $argHostinfo=explode(":",$argHostname); - $argHostname=$argHostinfo[0]; - $argHostport=$argHostinfo[1]; - } else { - $argHostport = empty($this->port)? "1521" : $this->port; - } - - if ($this->connectSID) { - $argDatabasename="(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=".$argHostname - .")(PORT=$argHostport))(CONNECT_DATA=(SID=$argDatabasename)))"; - } else - $argDatabasename="(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=".$argHostname - .")(PORT=$argHostport))(CONNECT_DATA=(SERVICE_NAME=$argDatabasename)))"; - } - } - - //if ($argHostname) print "<p>Connect: 1st argument should be left blank for $this->databaseType</p>"; - if ($mode==1) { - $this->_connectionID = ($this->charSet) ? - OCIPLogon($argUsername,$argPassword, $argDatabasename) - : - OCIPLogon($argUsername,$argPassword, $argDatabasename, $this->charSet) - ; - if ($this->_connectionID && $this->autoRollback) OCIrollback($this->_connectionID); - } else if ($mode==2) { - $this->_connectionID = ($this->charSet) ? - OCINLogon($argUsername,$argPassword, $argDatabasename) - : - OCINLogon($argUsername,$argPassword, $argDatabasename, $this->charSet); - - } else { - $this->_connectionID = ($this->charSet) ? - OCILogon($argUsername,$argPassword, $argDatabasename) - : - OCILogon($argUsername,$argPassword, $argDatabasename,$this->charSet); - } - if (!$this->_connectionID) return false; - if ($this->_initdate) { - $this->Execute("ALTER SESSION SET NLS_DATE_FORMAT='".$this->NLS_DATE_FORMAT."'"); - } - - // looks like: - // Oracle8i Enterprise Edition Release 8.1.7.0.0 - Production With the Partitioning option JServer Release 8.1.7.0.0 - Production - // $vers = OCIServerVersion($this->_connectionID); - // if (strpos($vers,'8i') !== false) $this->ansiOuter = true; - return true; - } - - function ServerInfo() - { - $arr['compat'] = $this->GetOne('select value from sys.database_compatible_level'); - $arr['description'] = @OCIServerVersion($this->_connectionID); - $arr['version'] = ADOConnection::_findvers($arr['description']); - return $arr; - } - // returns true or false - function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename) - { - return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename,1); - } - - // returns true or false - function _nconnect($argHostname, $argUsername, $argPassword, $argDatabasename) - { - return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename,2); - } - - function _affectedrows() - { - if (is_resource($this->_stmt)) return @OCIRowCount($this->_stmt); - return 0; - } - - function IfNull( $field, $ifNull ) - { - return " NVL($field, $ifNull) "; // if Oracle - } - - // format and return date string in database date format - function DBDate($d) - { - if (empty($d) && $d !== 0) return 'null'; - - if (is_string($d)) $d = ADORecordSet::UnixDate($d); - return "TO_DATE(".adodb_date($this->fmtDate,$d).",'".$this->NLS_DATE_FORMAT."')"; - } - - - // format and return date string in database timestamp format - function DBTimeStamp($ts) - { - if (empty($ts) && $ts !== 0) return 'null'; - if (is_string($ts)) $ts = ADORecordSet::UnixTimeStamp($ts); - return 'TO_DATE('.adodb_date($this->fmtTimeStamp,$ts).",'RRRR-MM-DD, HH:MI:SS AM')"; - } - - function RowLock($tables,$where,$flds='1 as ignore') - { - if ($this->autoCommit) $this->BeginTrans(); - return $this->GetOne("select $flds from $tables where $where for update"); - } - - function &MetaTables($ttype=false,$showSchema=false,$mask=false) - { - if ($mask) { - $save = $this->metaTablesSQL; - $mask = $this->qstr(strtoupper($mask)); - $this->metaTablesSQL .= " AND upper(table_name) like $mask"; - } - $ret =& ADOConnection::MetaTables($ttype,$showSchema); - - if ($mask) { - $this->metaTablesSQL = $save; - } - return $ret; - } - - // Mark Newnham - function &MetaIndexes ($table, $primary = FALSE, $owner=false) - { - // save old fetch mode - global $ADODB_FETCH_MODE; - - $save = $ADODB_FETCH_MODE; - $ADODB_FETCH_MODE = ADODB_FETCH_NUM; - - if ($this->fetchMode !== FALSE) { - $savem = $this->SetFetchMode(FALSE); - } - - // get index details - $table = strtoupper($table); - - // get Primary index - $primary_key = ''; - - $false = false; - $rs = $this->Execute(sprintf("SELECT * FROM ALL_CONSTRAINTS WHERE UPPER(TABLE_NAME)='%s' AND CONSTRAINT_TYPE='P'",$table)); - if ($row = $rs->FetchRow()) - $primary_key = $row[1]; //constraint_name - - if ($primary==TRUE && $primary_key=='') { - if (isset($savem)) - $this->SetFetchMode($savem); - $ADODB_FETCH_MODE = $save; - return $false; //There is no primary key - } - - $rs = $this->Execute(sprintf("SELECT ALL_INDEXES.INDEX_NAME, ALL_INDEXES.UNIQUENESS, ALL_IND_COLUMNS.COLUMN_POSITION, ALL_IND_COLUMNS.COLUMN_NAME FROM ALL_INDEXES,ALL_IND_COLUMNS WHERE UPPER(ALL_INDEXES.TABLE_NAME)='%s' AND ALL_IND_COLUMNS.INDEX_NAME=ALL_INDEXES.INDEX_NAME",$table)); - - - if (!is_object($rs)) { - if (isset($savem)) - $this->SetFetchMode($savem); - $ADODB_FETCH_MODE = $save; - return $false; - } - - $indexes = array (); - // parse index data into array - - while ($row = $rs->FetchRow()) { - if ($primary && $row[0] != $primary_key) continue; - if (!isset($indexes[$row[0]])) { - $indexes[$row[0]] = array( - 'unique' => ($row[1] == 'UNIQUE'), - 'columns' => array() - ); - } - $indexes[$row[0]]['columns'][$row[2] - 1] = $row[3]; - } - - // sort columns by order in the index - foreach ( array_keys ($indexes) as $index ) { - ksort ($indexes[$index]['columns']); - } - - if (isset($savem)) { - $this->SetFetchMode($savem); - $ADODB_FETCH_MODE = $save; - } - return $indexes; - } - - function BeginTrans() - { - if ($this->transOff) return true; - $this->transCnt += 1; - $this->autoCommit = false; - $this->_commit = OCI_DEFAULT; - return true; - } - - function CommitTrans($ok=true) - { - if ($this->transOff) return true; - if (!$ok) return $this->RollbackTrans(); - - if ($this->transCnt) $this->transCnt -= 1; - $ret = OCIcommit($this->_connectionID); - $this->_commit = OCI_COMMIT_ON_SUCCESS; - $this->autoCommit = true; - return $ret; - } - - function RollbackTrans() - { - if ($this->transOff) return true; - if ($this->transCnt) $this->transCnt -= 1; - $ret = OCIrollback($this->_connectionID); - $this->_commit = OCI_COMMIT_ON_SUCCESS; - $this->autoCommit = true; - return $ret; - } - - - function SelectDB($dbName) - { - return false; - } - - function ErrorMsg() - { - if ($this->_errorMsg !== false) return $this->_errorMsg; - - if (is_resource($this->_stmt)) $arr = @OCIerror($this->_stmt); - if (empty($arr)) { - $arr = @OCIerror($this->_connectionID); - if ($arr === false) $arr = @OCIError(); - if ($arr === false) return ''; - } - $this->_errorMsg = $arr['message']; - $this->_errorCode = $arr['code']; - return $this->_errorMsg; - } - - function ErrorNo() - { - if ($this->_errorCode !== false) return $this->_errorCode; - - if (is_resource($this->_stmt)) $arr = @OCIError($this->_stmt); - if (empty($arr)) { - $arr = @OCIError($this->_connectionID); - if ($arr == false) $arr = @OCIError(); - if ($arr == false) return ''; - } - - $this->_errorMsg = $arr['message']; - $this->_errorCode = $arr['code']; - - return $arr['code']; - } - - // Format date column in sql string given an input format that understands Y M D - function SQLDate($fmt, $col=false) - { - if (!$col) $col = $this->sysTimeStamp; - $s = 'TO_CHAR('.$col.",'"; - - $len = strlen($fmt); - for ($i=0; $i < $len; $i++) { - $ch = $fmt[$i]; - switch($ch) { - case 'Y': - case 'y': - $s .= 'YYYY'; - break; - case 'Q': - case 'q': - $s .= 'Q'; - break; - - case 'M': - $s .= 'Mon'; - break; - - case 'm': - $s .= 'MM'; - break; - case 'D': - case 'd': - $s .= 'DD'; - break; - - case 'H': - $s.= 'HH24'; - break; - - case 'h': - $s .= 'HH'; - break; - - case 'i': - $s .= 'MI'; - break; - - case 's': - $s .= 'SS'; - break; - - case 'a': - case 'A': - $s .= 'AM'; - break; - - case 'w': - $s .= 'D'; - break; - - case 'l': - $s .= 'DAY'; - break; - - case 'W': - $s .= 'WW'; - break; - - default: - // handle escape characters... - if ($ch == '\\') { - $i++; - $ch = substr($fmt,$i,1); - } - if (strpos('-/.:;, ',$ch) !== false) $s .= $ch; - else $s .= '"'.$ch.'"'; - - } - } - return $s. "')"; - } - - - /* - This algorithm makes use of - - a. FIRST_ROWS hint - The FIRST_ROWS hint explicitly chooses the approach to optimize response time, - that is, minimum resource usage to return the first row. Results will be returned - as soon as they are identified. - - b. Uses rownum tricks to obtain only the required rows from a given offset. - As this uses complicated sql statements, we only use this if the $offset >= 100. - This idea by Tomas V V Cox. - - This implementation does not appear to work with oracle 8.0.5 or earlier. Comment - out this function then, and the slower SelectLimit() in the base class will be used. - */ - function &SelectLimit($sql,$nrows=-1,$offset=-1, $inputarr=false,$secs2cache=0) - { - // seems that oracle only supports 1 hint comment in 8i - if ($this->firstrows) { - if (strpos($sql,'/*+') !== false) - $sql = str_replace('/*+ ','/*+FIRST_ROWS ',$sql); - else - $sql = preg_replace('/^[ \t\n]*select/i','SELECT /*+FIRST_ROWS*/',$sql); - } - - if ($offset < $this->selectOffsetAlg1) { - if ($nrows > 0) { - if ($offset > 0) $nrows += $offset; - //$inputarr['adodb_rownum'] = $nrows; - if ($this->databaseType == 'oci8po') { - $sql = "select * from (".$sql.") where rownum <= ?"; - } else { - $sql = "select * from (".$sql.") where rownum <= :adodb_offset"; - } - $inputarr['adodb_offset'] = $nrows; - $nrows = -1; - } - // note that $nrows = 0 still has to work ==> no rows returned - - $rs =& ADOConnection::SelectLimit($sql,$nrows,$offset,$inputarr,$secs2cache); - return $rs; - - } else { - // Algorithm by Tomas V V Cox, from PEAR DB oci8.php - - // Let Oracle return the name of the columns - $q_fields = "SELECT * FROM (".$sql.") WHERE NULL = NULL"; - - $false = false; - if (! $stmt_arr = $this->Prepare($q_fields)) { - return $false; - } - $stmt = $stmt_arr[1]; - - if (is_array($inputarr)) { - foreach($inputarr as $k => $v) { - if (is_array($v)) { - if (sizeof($v) == 2) // suggested by g.giunta@libero. - OCIBindByName($stmt,":$k",$inputarr[$k][0],$v[1]); - else - OCIBindByName($stmt,":$k",$inputarr[$k][0],$v[1],$v[2]); - } else { - $len = -1; - if ($v === ' ') $len = 1; - if (isset($bindarr)) { // is prepared sql, so no need to ocibindbyname again - $bindarr[$k] = $v; - } else { // dynamic sql, so rebind every time - OCIBindByName($stmt,":$k",$inputarr[$k],$len); - } - } - } - } - - if (!OCIExecute($stmt, OCI_DEFAULT)) { - OCIFreeStatement($stmt); - return $false; - } - - $ncols = OCINumCols($stmt); - for ( $i = 1; $i <= $ncols; $i++ ) { - $cols[] = '"'.OCIColumnName($stmt, $i).'"'; - } - $result = false; - - OCIFreeStatement($stmt); - $fields = implode(',', $cols); - $nrows += $offset; - $offset += 1; // in Oracle rownum starts at 1 - - if ($this->databaseType == 'oci8po') { - $sql = "SELECT $fields FROM". - "(SELECT rownum as adodb_rownum, $fields FROM". - " ($sql) WHERE rownum <= ?". - ") WHERE adodb_rownum >= ?"; - } else { - $sql = "SELECT $fields FROM". - "(SELECT rownum as adodb_rownum, $fields FROM". - " ($sql) WHERE rownum <= :adodb_nrows". - ") WHERE adodb_rownum >= :adodb_offset"; - } - $inputarr['adodb_nrows'] = $nrows; - $inputarr['adodb_offset'] = $offset; - - if ($secs2cache>0) $rs =& $this->CacheExecute($secs2cache, $sql,$inputarr); - else $rs =& $this->Execute($sql,$inputarr); - return $rs; - } - - } - - /** - * Usage: - * Store BLOBs and CLOBs - * - * Example: to store $var in a blob - * - * $conn->Execute('insert into TABLE (id,ablob) values(12,empty_blob())'); - * $conn->UpdateBlob('TABLE', 'ablob', $varHoldingBlob, 'ID=12', 'BLOB'); - * - * $blobtype supports 'BLOB' and 'CLOB', but you need to change to 'empty_clob()'. - * - * to get length of LOB: - * select DBMS_LOB.GETLENGTH(ablob) from TABLE - * - * If you are using CURSOR_SHARING = force, it appears this will case a segfault - * under oracle 8.1.7.0. Run: - * $db->Execute('ALTER SESSION SET CURSOR_SHARING=EXACT'); - * before UpdateBlob() then... - */ - - function UpdateBlob($table,$column,$val,$where,$blobtype='BLOB') - { - - //if (strlen($val) < 4000) return $this->Execute("UPDATE $table SET $column=:blob WHERE $where",array('blob'=>$val)) != false; - - switch(strtoupper($blobtype)) { - default: ADOConnection::outp("<b>UpdateBlob</b>: Unknown blobtype=$blobtype"); return false; - case 'BLOB': $type = OCI_B_BLOB; break; - case 'CLOB': $type = OCI_B_CLOB; break; - } - - if ($this->databaseType == 'oci8po') - $sql = "UPDATE $table set $column=EMPTY_{$blobtype}() WHERE $where RETURNING $column INTO ?"; - else - $sql = "UPDATE $table set $column=EMPTY_{$blobtype}() WHERE $where RETURNING $column INTO :blob"; - - $desc = OCINewDescriptor($this->_connectionID, OCI_D_LOB); - $arr['blob'] = array($desc,-1,$type); - if ($this->session_sharing_force_blob) $this->Execute('ALTER SESSION SET CURSOR_SHARING=EXACT'); - $commit = $this->autoCommit; - if ($commit) $this->BeginTrans(); - $rs = $this->_Execute($sql,$arr); - if ($rez = !empty($rs)) $desc->save($val); - $desc->free(); - if ($commit) $this->CommitTrans(); - if ($this->session_sharing_force_blob) $this->Execute('ALTER SESSION SET CURSOR_SHARING=FORCE'); - - if ($rez) $rs->Close(); - return $rez; - } - - /** - * Usage: store file pointed to by $var in a blob - */ - function UpdateBlobFile($table,$column,$val,$where,$blobtype='BLOB') - { - switch(strtoupper($blobtype)) { - default: ADOConnection::outp( "<b>UpdateBlob</b>: Unknown blobtype=$blobtype"); return false; - case 'BLOB': $type = OCI_B_BLOB; break; - case 'CLOB': $type = OCI_B_CLOB; break; - } - - if ($this->databaseType == 'oci8po') - $sql = "UPDATE $table set $column=EMPTY_{$blobtype}() WHERE $where RETURNING $column INTO ?"; - else - $sql = "UPDATE $table set $column=EMPTY_{$blobtype}() WHERE $where RETURNING $column INTO :blob"; - - $desc = OCINewDescriptor($this->_connectionID, OCI_D_LOB); - $arr['blob'] = array($desc,-1,$type); - - $this->BeginTrans(); - $rs = ADODB_oci8::Execute($sql,$arr); - if ($rez = !empty($rs)) $desc->savefile($val); - $desc->free(); - $this->CommitTrans(); - - if ($rez) $rs->Close(); - return $rez; - } - - /** - * Execute SQL - * - * @param sql SQL statement to execute, or possibly an array holding prepared statement ($sql[0] will hold sql text) - * @param [inputarr] holds the input data to bind to. Null elements will be set to null. - * @return RecordSet or false - */ - function &Execute($sql,$inputarr=false) - { - if ($this->fnExecute) { - $fn = $this->fnExecute; - $ret =& $fn($this,$sql,$inputarr); - if (isset($ret)) return $ret; - } - if ($inputarr) { - #if (!is_array($inputarr)) $inputarr = array($inputarr); - - $element0 = reset($inputarr); - - # is_object check because oci8 descriptors can be passed in - if (is_array($element0) && !is_object(reset($element0))) { - if (is_string($sql)) - $stmt = $this->Prepare($sql); - else - $stmt = $sql; - - foreach($inputarr as $arr) { - $ret =& $this->_Execute($stmt,$arr); - if (!$ret) return $ret; - } - } else { - $ret =& $this->_Execute($sql,$inputarr); - } - - } else { - $ret =& $this->_Execute($sql,false); - } - - return $ret; - } - - /* - Example of usage: - - $stmt = $this->Prepare('insert into emp (empno, ename) values (:empno, :ename)'); - */ - function Prepare($sql,$cursor=false) - { - static $BINDNUM = 0; - - $stmt = OCIParse($this->_connectionID,$sql); - - if (!$stmt) return false; - - $BINDNUM += 1; - - $sttype = @OCIStatementType($stmt); - if ($sttype == 'BEGIN' || $sttype == 'DECLARE') { - return array($sql,$stmt,0,$BINDNUM, ($cursor) ? OCINewCursor($this->_connectionID) : false); - } - return array($sql,$stmt,0,$BINDNUM); - } - - /* - Call an oracle stored procedure and returns a cursor variable as a recordset. - Concept by Robert Tuttle robert@ud.com - - Example: - Note: we return a cursor variable in :RS2 - $rs = $db->ExecuteCursor("BEGIN adodb.open_tab(:RS2); END;",'RS2'); - - $rs = $db->ExecuteCursor( - "BEGIN :RS2 = adodb.getdata(:VAR1); END;", - 'RS2', - array('VAR1' => 'Mr Bean')); - - */ - function &ExecuteCursor($sql,$cursorName='rs',$params=false) - { - if (is_array($sql)) $stmt = $sql; - else $stmt = ADODB_oci8::Prepare($sql,true); # true to allocate OCINewCursor - - if (is_array($stmt) && sizeof($stmt) >= 5) { - $hasref = true; - $ignoreCur = false; - $this->Parameter($stmt, $ignoreCur, $cursorName, false, -1, OCI_B_CURSOR); - if ($params) { - foreach($params as $k => $v) { - $this->Parameter($stmt,$params[$k], $k); - } - } - } else - $hasref = false; - - $rs =& $this->Execute($stmt); - if ($rs) { - if ($rs->databaseType == 'array') OCIFreeCursor($stmt[4]); - else if ($hasref) $rs->_refcursor = $stmt[4]; - } - return $rs; - } - - /* - Bind a variable -- very, very fast for executing repeated statements in oracle. - Better than using - for ($i = 0; $i < $max; $i++) { - $p1 = ?; $p2 = ?; $p3 = ?; - $this->Execute("insert into table (col0, col1, col2) values (:0, :1, :2)", - array($p1,$p2,$p3)); - } - - Usage: - $stmt = $DB->Prepare("insert into table (col0, col1, col2) values (:0, :1, :2)"); - $DB->Bind($stmt, $p1); - $DB->Bind($stmt, $p2); - $DB->Bind($stmt, $p3); - for ($i = 0; $i < $max; $i++) { - $p1 = ?; $p2 = ?; $p3 = ?; - $DB->Execute($stmt); - } - - Some timings: - ** Test table has 3 cols, and 1 index. Test to insert 1000 records - Time 0.6081s (1644.60 inserts/sec) with direct OCIParse/OCIExecute - Time 0.6341s (1577.16 inserts/sec) with ADOdb Prepare/Bind/Execute - Time 1.5533s ( 643.77 inserts/sec) with pure SQL using Execute - - Now if PHP only had batch/bulk updating like Java or PL/SQL... - - Note that the order of parameters differs from OCIBindByName, - because we default the names to :0, :1, :2 - */ - function Bind(&$stmt,&$var,$size=4000,$type=false,$name=false,$isOutput=false) - { - - if (!is_array($stmt)) return false; - - if (($type == OCI_B_CURSOR) && sizeof($stmt) >= 5) { - return OCIBindByName($stmt[1],":".$name,$stmt[4],$size,$type); - } - - if ($name == false) { - if ($type !== false) $rez = OCIBindByName($stmt[1],":".$stmt[2],$var,$size,$type); - else $rez = OCIBindByName($stmt[1],":".$stmt[2],$var,$size); // +1 byte for null terminator - $stmt[2] += 1; - } else if (oci_lob_desc($type)) { - if ($this->debug) { - ADOConnection::outp("<b>Bind</b>: name = $name"); - } - //we have to create a new Descriptor here - $numlob = count($this->_refLOBs); - $this->_refLOBs[$numlob]['LOB'] = OCINewDescriptor($this->_connectionID, oci_lob_desc($type)); - $this->_refLOBs[$numlob]['TYPE'] = $isOutput; - - $tmp = &$this->_refLOBs[$numlob]['LOB']; - $rez = OCIBindByName($stmt[1], ":".$name, $tmp, -1, $type); - if ($this->debug) { - ADOConnection::outp("<b>Bind</b>: descriptor has been allocated, var (".$name.") binded"); - } - - // if type is input then write data to lob now - if ($isOutput == false) { - $var = $this->BlobEncode($var); - $tmp->WriteTemporary($var); - $this->_refLOBs[$numlob]['VAR'] = &$var; - if ($this->debug) { - ADOConnection::outp("<b>Bind</b>: LOB has been written to temp"); - } - } else { - $this->_refLOBs[$numlob]['VAR'] = &$var; - } - $rez = $tmp; - } else { - if ($this->debug) - ADOConnection::outp("<b>Bind</b>: name = $name"); - - if ($type !== false) $rez = OCIBindByName($stmt[1],":".$name,$var,$size,$type); - else $rez = OCIBindByName($stmt[1],":".$name,$var,$size); // +1 byte for null terminator - } - - return $rez; - } - - function Param($name,$type=false) - { - return ':'.$name; - } - - /* - Usage: - $stmt = $db->Prepare('select * from table where id =:myid and group=:group'); - $db->Parameter($stmt,$id,'myid'); - $db->Parameter($stmt,$group,'group'); - $db->Execute($stmt); - - @param $stmt Statement returned by Prepare() or PrepareSP(). - @param $var PHP variable to bind to - @param $name Name of stored procedure variable name to bind to. - @param [$isOutput] Indicates direction of parameter 0/false=IN 1=OUT 2= IN/OUT. This is ignored in oci8. - @param [$maxLen] Holds an maximum length of the variable. - @param [$type] The data type of $var. Legal values depend on driver. - - See OCIBindByName documentation at php.net. - */ - function Parameter(&$stmt,&$var,$name,$isOutput=false,$maxLen=4000,$type=false) - { - if ($this->debug) { - $prefix = ($isOutput) ? 'Out' : 'In'; - $ztype = (empty($type)) ? 'false' : $type; - ADOConnection::outp( "{$prefix}Parameter(\$stmt, \$php_var='$var', \$name='$name', \$maxLen=$maxLen, \$type=$ztype);"); - } - return $this->Bind($stmt,$var,$maxLen,$type,$name,$isOutput); - } - - /* - returns query ID if successful, otherwise false - this version supports: - - 1. $db->execute('select * from table'); - - 2. $db->prepare('insert into table (a,b,c) values (:0,:1,:2)'); - $db->execute($prepared_statement, array(1,2,3)); - - 3. $db->execute('insert into table (a,b,c) values (:a,:b,:c)',array('a'=>1,'b'=>2,'c'=>3)); - - 4. $db->prepare('insert into table (a,b,c) values (:0,:1,:2)'); - $db->bind($stmt,1); $db->bind($stmt,2); $db->bind($stmt,3); - $db->execute($stmt); - */ - function _query($sql,$inputarr) - { - if (is_array($sql)) { // is prepared sql - $stmt = $sql[1]; - - // we try to bind to permanent array, so that OCIBindByName is persistent - // and carried out once only - note that max array element size is 4000 chars - if (is_array($inputarr)) { - $bindpos = $sql[3]; - if (isset($this->_bind[$bindpos])) { - // all tied up already - $bindarr = &$this->_bind[$bindpos]; - } else { - // one statement to bind them all - $bindarr = array(); - foreach($inputarr as $k => $v) { - $bindarr[$k] = $v; - OCIBindByName($stmt,":$k",$bindarr[$k],is_string($v) && strlen($v)>4000 ? -1 : 4000); - } - $this->_bind[$bindpos] = &$bindarr; - } - } - } else { - $stmt=OCIParse($this->_connectionID,$sql); - } - - $this->_stmt = $stmt; - if (!$stmt) return false; - - if (defined('ADODB_PREFETCH_ROWS')) @OCISetPrefetch($stmt,ADODB_PREFETCH_ROWS); - - if (is_array($inputarr)) { - foreach($inputarr as $k => $v) { - if (is_array($v)) { - if (sizeof($v) == 2) // suggested by g.giunta@libero. - OCIBindByName($stmt,":$k",$inputarr[$k][0],$v[1]); - else - OCIBindByName($stmt,":$k",$inputarr[$k][0],$v[1],$v[2]); - - if ($this->debug==99) echo "name=:$k",' var='.$inputarr[$k][0],' len='.$v[1],' type='.$v[2],'<br>'; - } else { - $len = -1; - if ($v === ' ') $len = 1; - if (isset($bindarr)) { // is prepared sql, so no need to ocibindbyname again - $bindarr[$k] = $v; - } else { // dynamic sql, so rebind every time - OCIBindByName($stmt,":$k",$inputarr[$k],$len); - } - } - } - } - - $this->_errorMsg = false; - $this->_errorCode = false; - if (OCIExecute($stmt,$this->_commit)) { -//OCIInternalDebug(1); - if (count($this -> _refLOBs) > 0) { - - foreach ($this -> _refLOBs as $key => $value) { - if ($this -> _refLOBs[$key]['TYPE'] == true) { - $tmp = $this -> _refLOBs[$key]['LOB'] -> load(); - if ($this -> debug) { - ADOConnection::outp("<b>OUT LOB</b>: LOB has been loaded. <br>"); - } - //$_GLOBALS[$this -> _refLOBs[$key]['VAR']] = $tmp; - $this -> _refLOBs[$key]['VAR'] = $tmp; - } else { - $this->_refLOBs[$key]['LOB']->save($this->_refLOBs[$key]['VAR']); - $this -> _refLOBs[$key]['LOB']->free(); - unset($this -> _refLOBs[$key]); - if ($this->debug) { - ADOConnection::outp("<b>IN LOB</b>: LOB has been saved. <br>"); - } - } - } - } - - switch (@OCIStatementType($stmt)) { - case "SELECT": - return $stmt; - - case 'DECLARE': - case "BEGIN": - if (is_array($sql) && !empty($sql[4])) { - $cursor = $sql[4]; - if (is_resource($cursor)) { - $ok = OCIExecute($cursor); - return $cursor; - } - return $stmt; - } else { - if (is_resource($stmt)) { - OCIFreeStatement($stmt); - return true; - } - return $stmt; - } - break; - default : - // ociclose -- no because it could be used in a LOB? - return true; - } - } - return false; - } - - // returns true or false - function _close() - { - if (!$this->_connectionID) return; - - if (!$this->autoCommit) OCIRollback($this->_connectionID); - if (count($this->_refLOBs) > 0) { - foreach ($this ->_refLOBs as $key => $value) { - $this->_refLOBs[$key]['LOB']->free(); - unset($this->_refLOBs[$key]); - } - } - OCILogoff($this->_connectionID); - - $this->_stmt = false; - $this->_connectionID = false; - } - - function MetaPrimaryKeys($table, $owner=false,$internalKey=false) - { - if ($internalKey) return array('ROWID'); - - // tested with oracle 8.1.7 - $table = strtoupper($table); - if ($owner) { - $owner_clause = "AND ((a.OWNER = b.OWNER) AND (a.OWNER = UPPER('$owner')))"; - $ptab = 'ALL_'; - } else { - $owner_clause = ''; - $ptab = 'USER_'; - } - $sql = " -SELECT /*+ RULE */ distinct b.column_name - FROM {$ptab}CONSTRAINTS a - , {$ptab}CONS_COLUMNS b - WHERE ( UPPER(b.table_name) = ('$table')) - AND (UPPER(a.table_name) = ('$table') and a.constraint_type = 'P') - $owner_clause - AND (a.constraint_name = b.constraint_name)"; - - $rs = $this->Execute($sql); - if ($rs && !$rs->EOF) { - $arr =& $rs->GetArray(); - $a = array(); - foreach($arr as $v) { - $a[] = reset($v); - } - return $a; - } - else return false; - } - - // http://gis.mit.edu/classes/11.521/sqlnotes/referential_integrity.html - function MetaForeignKeys($table, $owner=false) - { - global $ADODB_FETCH_MODE; - - $save = $ADODB_FETCH_MODE; - $ADODB_FETCH_MODE = ADODB_FETCH_NUM; - $table = $this->qstr(strtoupper($table)); - if (!$owner) { - $owner = $this->user; - $tabp = 'user_'; - } else - $tabp = 'all_'; - - $owner = ' and owner='.$this->qstr(strtoupper($owner)); - - $sql = -"select constraint_name,r_owner,r_constraint_name - from {$tabp}constraints - where constraint_type = 'R' and table_name = $table $owner"; - - $constraints =& $this->GetArray($sql); - $arr = false; - foreach($constraints as $constr) { - $cons = $this->qstr($constr[0]); - $rowner = $this->qstr($constr[1]); - $rcons = $this->qstr($constr[2]); - $cols = $this->GetArray("select column_name from {$tabp}cons_columns where constraint_name=$cons $owner order by position"); - $tabcol = $this->GetArray("select table_name,column_name from {$tabp}cons_columns where owner=$rowner and constraint_name=$rcons order by position"); - - if ($cols && $tabcol) - for ($i=0, $max=sizeof($cols); $i < $max; $i++) { - $arr[$tabcol[$i][0]] = $cols[$i][0].'='.$tabcol[$i][1]; - } - } - $ADODB_FETCH_MODE = $save; - - return $arr; - } - - - function CharMax() - { - return 4000; - } - - function TextMax() - { - return 4000; - } - - /** - * Quotes a string. - * An example is $db->qstr("Don't bother",magic_quotes_runtime()); - * - * @param s the string to quote - * @param [magic_quotes] if $s is GET/POST var, set to get_magic_quotes_gpc(). - * This undoes the stupidity of magic quotes for GPC. - * - * @return quoted string to be sent back to database - */ - function qstr($s,$magic_quotes=false) - { - //$nofixquotes=false; - - if ($this->noNullStrings && strlen($s)==0)$s = ' '; - if (!$magic_quotes) { - if ($this->replaceQuote[0] == '\\'){ - $s = str_replace('\\','\\\\',$s); - } - return "'".str_replace("'",$this->replaceQuote,$s)."'"; - } - - // undo magic quotes for " - $s = str_replace('\\"','"',$s); - - $s = str_replace('\\\\','\\',$s); - return "'".str_replace("\\'",$this->replaceQuote,$s)."'"; - - } - -} - -/*-------------------------------------------------------------------------------------- - Class Name: Recordset ---------------------------------------------------------------------------------------*/ - -class ADORecordset_oci8 extends ADORecordSet { - - var $databaseType = 'oci8'; - var $bind=false; - var $_fieldobjs; - - //var $_arr = false; - - function ADORecordset_oci8($queryID,$mode=false) - { - if ($mode === false) { - global $ADODB_FETCH_MODE; - $mode = $ADODB_FETCH_MODE; - } - switch ($mode) - { - case ADODB_FETCH_ASSOC:$this->fetchMode = OCI_ASSOC+OCI_RETURN_NULLS+OCI_RETURN_LOBS; break; - case ADODB_FETCH_DEFAULT: - case ADODB_FETCH_BOTH:$this->fetchMode = OCI_NUM+OCI_ASSOC+OCI_RETURN_NULLS+OCI_RETURN_LOBS; break; - case ADODB_FETCH_NUM: - default: - $this->fetchMode = OCI_NUM+OCI_RETURN_NULLS+OCI_RETURN_LOBS; break; - } - - $this->adodbFetchMode = $mode; - $this->_queryID = $queryID; - } - - - function Init() - { - if ($this->_inited) return; - - $this->_inited = true; - if ($this->_queryID) { - - $this->_currentRow = 0; - @$this->_initrs(); - $this->EOF = !$this->_fetch(); - - /* - // based on idea by Gaetano Giunta to detect unusual oracle errors - // see http://phplens.com/lens/lensforum/msgs.php?id=6771 - $err = OCIError($this->_queryID); - if ($err && $this->connection->debug) ADOConnection::outp($err); - */ - - if (!is_array($this->fields)) { - $this->_numOfRows = 0; - $this->fields = array(); - } - } else { - $this->fields = array(); - $this->_numOfRows = 0; - $this->_numOfFields = 0; - $this->EOF = true; - } - } - - function _initrs() - { - $this->_numOfRows = -1; - $this->_numOfFields = OCInumcols($this->_queryID); - if ($this->_numOfFields>0) { - $this->_fieldobjs = array(); - $max = $this->_numOfFields; - for ($i=0;$i<$max; $i++) $this->_fieldobjs[] = $this->_FetchField($i); - } - } - - /* Returns: an object containing field information. - Get column information in the Recordset object. fetchField() can be used in order to obtain information about - fields in a certain query result. If the field offset isn't specified, the next field that wasn't yet retrieved by - fetchField() is retrieved. */ - - function &_FetchField($fieldOffset = -1) - { - $fld = new ADOFieldObject; - $fieldOffset += 1; - $fld->name =OCIcolumnname($this->_queryID, $fieldOffset); - $fld->type = OCIcolumntype($this->_queryID, $fieldOffset); - $fld->max_length = OCIcolumnsize($this->_queryID, $fieldOffset); - if ($fld->type == 'NUMBER') { - $p = OCIColumnPrecision($this->_queryID, $fieldOffset); - $sc = OCIColumnScale($this->_queryID, $fieldOffset); - if ($p != 0 && $sc == 0) $fld->type = 'INT'; - //echo " $this->name ($p.$sc) "; - } - return $fld; - } - - /* For some reason, OCIcolumnname fails when called after _initrs() so we cache it */ - function &FetchField($fieldOffset = -1) - { - return $this->_fieldobjs[$fieldOffset]; - } - - - /* - // 10% speedup to move MoveNext to child class - function _MoveNext() - { - //global $ADODB_EXTENSION;if ($ADODB_EXTENSION) return @adodb_movenext($this); - - if ($this->EOF) return false; - - $this->_currentRow++; - if(@OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode)) - return true; - $this->EOF = true; - - return false; - } */ - - - function MoveNext() - { - if (@OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode)) { - $this->_currentRow += 1; - return true; - } - if (!$this->EOF) { - $this->_currentRow += 1; - $this->EOF = true; - } - return false; - } - - /* - # does not work as first record is retrieved in _initrs(), so is not included in GetArray() - function &GetArray($nRows = -1) - { - global $ADODB_OCI8_GETARRAY; - - if (true || !empty($ADODB_OCI8_GETARRAY)) { - # does not support $ADODB_ANSI_PADDING_OFF - - //OCI_RETURN_NULLS and OCI_RETURN_LOBS is set by OCIfetchstatement - switch($this->adodbFetchMode) { - case ADODB_FETCH_NUM: - - $ncols = @OCIfetchstatement($this->_queryID, $results, 0, $nRows, OCI_FETCHSTATEMENT_BY_ROW+OCI_NUM); - $results = array_merge(array($this->fields),$results); - return $results; - - case ADODB_FETCH_ASSOC: - if (ADODB_ASSOC_CASE != 2 || $this->databaseType != 'oci8') break; - - $ncols = @OCIfetchstatement($this->_queryID, $assoc, 0, $nRows, OCI_FETCHSTATEMENT_BY_ROW); - $results =& array_merge(array($this->fields),$assoc); - return $results; - - default: - break; - } - } - - $results =& ADORecordSet::GetArray($nRows); - return $results; - - } */ - - /* Optimize SelectLimit() by using OCIFetch() instead of OCIFetchInto() */ - function &GetArrayLimit($nrows,$offset=-1) - { - if ($offset <= 0) { - $arr =& $this->GetArray($nrows); - return $arr; - } - for ($i=1; $i < $offset; $i++) - if (!@OCIFetch($this->_queryID)) return array(); - - if (!@OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode)) return array(); - $results = array(); - $cnt = 0; - while (!$this->EOF && $nrows != $cnt) { - $results[$cnt++] = $this->fields; - $this->MoveNext(); - } - - return $results; - } - - - /* Use associative array to get fields array */ - function Fields($colname) - { - if (!$this->bind) { - $this->bind = array(); - for ($i=0; $i < $this->_numOfFields; $i++) { - $o = $this->FetchField($i); - $this->bind[strtoupper($o->name)] = $i; - } - } - - return $this->fields[$this->bind[strtoupper($colname)]]; - } - - - - function _seek($row) - { - return false; - } - - function _fetch() - { - return @OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode); - } - - /* close() only needs to be called if you are worried about using too much memory while your script - is running. All associated result memory for the specified result identifier will automatically be freed. */ - - function _close() - { - if ($this->connection->_stmt === $this->_queryID) $this->connection->_stmt = false; - if (!empty($this->_refcursor)) { - OCIFreeCursor($this->_refcursor); - $this->_refcursor = false; - } - @OCIFreeStatement($this->_queryID); - $this->_queryID = false; - - } - - function MetaType($t,$len=-1) - { - if (is_object($t)) { - $fieldobj = $t; - $t = $fieldobj->type; - $len = $fieldobj->max_length; - } - switch (strtoupper($t)) { - case 'VARCHAR': - case 'VARCHAR2': - case 'CHAR': - case 'VARBINARY': - case 'BINARY': - case 'NCHAR': - case 'NVARCHAR': - case 'NVARCHAR2': - if (isset($this) && $len <= $this->blobSize) return 'C'; - - case 'NCLOB': - case 'LONG': - case 'LONG VARCHAR': - case 'CLOB': - return 'X'; - - case 'LONG RAW': - case 'LONG VARBINARY': - case 'BLOB': - return 'B'; - - case 'DATE': - return ($this->connection->datetime) ? 'T' : 'D'; - - - case 'TIMESTAMP': return 'T'; - - case 'INT': - case 'SMALLINT': - case 'INTEGER': - return 'I'; - - default: return 'N'; - } - } -} - -class ADORecordSet_ext_oci8 extends ADORecordSet_oci8 { - function ADORecordSet_ext_oci8($queryID,$mode=false) - { - if ($mode === false) { - global $ADODB_FETCH_MODE; - $mode = $ADODB_FETCH_MODE; - } - switch ($mode) - { - case ADODB_FETCH_ASSOC:$this->fetchMode = OCI_ASSOC+OCI_RETURN_NULLS+OCI_RETURN_LOBS; break; - case ADODB_FETCH_DEFAULT: - case ADODB_FETCH_BOTH:$this->fetchMode = OCI_NUM+OCI_ASSOC+OCI_RETURN_NULLS+OCI_RETURN_LOBS; break; - case ADODB_FETCH_NUM: - default: $this->fetchMode = OCI_NUM+OCI_RETURN_NULLS+OCI_RETURN_LOBS; break; - } - $this->adodbFetchMode = $mode; - $this->_queryID = $queryID; - } - - function MoveNext() - { - return adodb_movenext($this); - } -} -?> diff --git a/framework/3rdParty/adodb/drivers/adodb-oci805.inc.php b/framework/3rdParty/adodb/drivers/adodb-oci805.inc.php deleted file mode 100644 index 5163df09..00000000 --- a/framework/3rdParty/adodb/drivers/adodb-oci805.inc.php +++ /dev/null @@ -1,59 +0,0 @@ -<?php -/** - * @version V4.81 3 May 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved. - * Released under both BSD license and Lesser GPL library license. - * Whenever there is any discrepancy between the two licenses, - * the BSD license will take precedence. - * - * Set tabs to 4 for best viewing. - * - * Latest version is available at http://php.weblogs.com - * - * Oracle 8.0.5 driver -*/ - -// security - hide paths -if (!defined('ADODB_DIR')) die(); - -include_once(ADODB_DIR.'/drivers/adodb-oci8.inc.php'); - -class ADODB_oci805 extends ADODB_oci8 { - var $databaseType = "oci805"; - var $connectSID = true; - - function ADODB_oci805() - { - $this->ADODB_oci8(); - } - - function &SelectLimit($sql,$nrows=-1,$offset=-1, $inputarr=false,$secs2cache=0) - { - // seems that oracle only supports 1 hint comment in 8i - if (strpos($sql,'/*+') !== false) - $sql = str_replace('/*+ ','/*+FIRST_ROWS ',$sql); - else - $sql = preg_replace('/^[ \t\n]*select/i','SELECT /*+FIRST_ROWS*/',$sql); - - /* - The following is only available from 8.1.5 because order by in inline views not - available before then... - http://www.jlcomp.demon.co.uk/faq/top_sql.html - if ($nrows > 0) { - if ($offset > 0) $nrows += $offset; - $sql = "select * from ($sql) where rownum <= $nrows"; - $nrows = -1; - } - */ - - return ADOConnection::SelectLimit($sql,$nrows,$offset,$inputarr,$secs2cache); - } -} - -class ADORecordset_oci805 extends ADORecordset_oci8 { - var $databaseType = "oci805"; - function ADORecordset_oci805($id,$mode=false) - { - $this->ADORecordset_oci8($id,$mode); - } -} -?>
\ No newline at end of file diff --git a/framework/3rdParty/adodb/drivers/adodb-oci8po.inc.php b/framework/3rdParty/adodb/drivers/adodb-oci8po.inc.php deleted file mode 100644 index 0555864a..00000000 --- a/framework/3rdParty/adodb/drivers/adodb-oci8po.inc.php +++ /dev/null @@ -1,217 +0,0 @@ -<?php -/* -V4.81 3 May 2006 (c) 2000-2006 John Lim. All rights reserved. - Released under both BSD license and Lesser GPL library license. - Whenever there is any discrepancy between the two licenses, - the BSD license will take precedence. - - Latest version is available at http://adodb.sourceforge.net - - Portable version of oci8 driver, to make it more similar to other database drivers. - The main differences are - - 1. that the OCI_ASSOC names are in lowercase instead of uppercase. - 2. bind variables are mapped using ? instead of :<bindvar> - - Should some emulation of RecordCount() be implemented? - -*/ - -// security - hide paths -if (!defined('ADODB_DIR')) die(); - -include_once(ADODB_DIR.'/drivers/adodb-oci8.inc.php'); - -class ADODB_oci8po extends ADODB_oci8 { - var $databaseType = 'oci8po'; - var $dataProvider = 'oci8'; - var $metaColumnsSQL = "select lower(cname),coltype,width, SCALE, PRECISION, NULLS, DEFAULTVAL from col where tname='%s' order by colno"; //changed by smondino@users.sourceforge. net - var $metaTablesSQL = "select lower(table_name),table_type from cat where table_type in ('TABLE','VIEW')"; - - function ADODB_oci8po() - { - $this->_hasOCIFetchStatement = ADODB_PHPVER >= 0x4200; - # oci8po does not support adodb extension: adodb_movenext() - } - - function Param($name) - { - return '?'; - } - - function Prepare($sql,$cursor=false) - { - $sqlarr = explode('?',$sql); - $sql = $sqlarr[0]; - for ($i = 1, $max = sizeof($sqlarr); $i < $max; $i++) { - $sql .= ':'.($i-1) . $sqlarr[$i]; - } - return ADODB_oci8::Prepare($sql,$cursor); - } - - // emulate handling of parameters ? ?, replacing with :bind0 :bind1 - function _query($sql,$inputarr) - { - if (is_array($inputarr)) { - $i = 0; - if (is_array($sql)) { - foreach($inputarr as $v) { - $arr['bind'.$i++] = $v; - } - } else { - $sqlarr = explode('?',$sql); - $sql = $sqlarr[0]; - foreach($inputarr as $k => $v) { - $sql .= ":$k" . $sqlarr[++$i]; - } - } - } - return ADODB_oci8::_query($sql,$inputarr); - } -} - -/*-------------------------------------------------------------------------------------- - Class Name: Recordset ---------------------------------------------------------------------------------------*/ - -class ADORecordset_oci8po extends ADORecordset_oci8 { - - var $databaseType = 'oci8po'; - - function ADORecordset_oci8po($queryID,$mode=false) - { - $this->ADORecordset_oci8($queryID,$mode); - } - - function Fields($colname) - { - if ($this->fetchMode & OCI_ASSOC) return $this->fields[$colname]; - - if (!$this->bind) { - $this->bind = array(); - for ($i=0; $i < $this->_numOfFields; $i++) { - $o = $this->FetchField($i); - $this->bind[strtoupper($o->name)] = $i; - } - } - return $this->fields[$this->bind[strtoupper($colname)]]; - } - - // lowercase field names... - function &_FetchField($fieldOffset = -1) - { - $fld = new ADOFieldObject; - $fieldOffset += 1; - $fld->name = strtolower(OCIcolumnname($this->_queryID, $fieldOffset)); - $fld->type = OCIcolumntype($this->_queryID, $fieldOffset); - $fld->max_length = OCIcolumnsize($this->_queryID, $fieldOffset); - if ($fld->type == 'NUMBER') { - //$p = OCIColumnPrecision($this->_queryID, $fieldOffset); - $sc = OCIColumnScale($this->_queryID, $fieldOffset); - if ($sc == 0) $fld->type = 'INT'; - } - return $fld; - } - /* - function MoveNext() - { - if (@OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode)) { - $this->_currentRow += 1; - return true; - } - if (!$this->EOF) { - $this->_currentRow += 1; - $this->EOF = true; - } - return false; - }*/ - - // 10% speedup to move MoveNext to child class - function MoveNext() - { - if(@OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode)) { - global $ADODB_ANSI_PADDING_OFF; - $this->_currentRow++; - - if ($this->fetchMode & OCI_ASSOC) $this->_updatefields(); - if (!empty($ADODB_ANSI_PADDING_OFF)) { - foreach($this->fields as $k => $v) { - if (is_string($v)) $this->fields[$k] = rtrim($v); - } - } - return true; - } - if (!$this->EOF) { - $this->EOF = true; - $this->_currentRow++; - } - return false; - } - - /* Optimize SelectLimit() by using OCIFetch() instead of OCIFetchInto() */ - function &GetArrayLimit($nrows,$offset=-1) - { - if ($offset <= 0) { - $arr = $this->GetArray($nrows); - return $arr; - } - for ($i=1; $i < $offset; $i++) - if (!@OCIFetch($this->_queryID)) { - $arr = array(); - return $arr; - } - if (!@OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode)) { - $arr = array(); - return $arr; - } - if ($this->fetchMode & OCI_ASSOC) $this->_updatefields(); - $results = array(); - $cnt = 0; - while (!$this->EOF && $nrows != $cnt) { - $results[$cnt++] = $this->fields; - $this->MoveNext(); - } - - return $results; - } - - // Create associative array - function _updatefields() - { - if (ADODB_ASSOC_CASE == 2) return; // native - - $arr = array(); - $lowercase = (ADODB_ASSOC_CASE == 0); - - foreach($this->fields as $k => $v) { - if (is_integer($k)) $arr[$k] = $v; - else { - if ($lowercase) - $arr[strtolower($k)] = $v; - else - $arr[strtoupper($k)] = $v; - } - } - $this->fields = $arr; - } - - function _fetch() - { - $ret = @OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode); - if ($ret) { - global $ADODB_ANSI_PADDING_OFF; - - if ($this->fetchMode & OCI_ASSOC) $this->_updatefields(); - if (!empty($ADODB_ANSI_PADDING_OFF)) { - foreach($this->fields as $k => $v) { - if (is_string($v)) $this->fields[$k] = rtrim($v); - } - } - } - return $ret; - } - -} - - -?>
\ No newline at end of file diff --git a/framework/3rdParty/adodb/drivers/adodb-odbc.inc.php b/framework/3rdParty/adodb/drivers/adodb-odbc.inc.php deleted file mode 100644 index adf07bd4..00000000 --- a/framework/3rdParty/adodb/drivers/adodb-odbc.inc.php +++ /dev/null @@ -1,738 +0,0 @@ -<?php -/* -V4.81 3 May 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved. - Released under both BSD license and Lesser GPL library license. - Whenever there is any discrepancy between the two licenses, - the BSD license will take precedence. -Set tabs to 4 for best viewing. - - Latest version is available at http://adodb.sourceforge.net - - Requires ODBC. Works on Windows and Unix. -*/ -// security - hide paths -if (!defined('ADODB_DIR')) die(); - - define("_ADODB_ODBC_LAYER", 2 ); - -/*-------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------*/ - - -class ADODB_odbc extends ADOConnection { - var $databaseType = "odbc"; - var $fmtDate = "'Y-m-d'"; - var $fmtTimeStamp = "'Y-m-d, h:i:sA'"; - var $replaceQuote = "''"; // string to use to replace quotes - var $dataProvider = "odbc"; - var $hasAffectedRows = true; - var $binmode = ODBC_BINMODE_RETURN; - var $useFetchArray = false; // setting this to true will make array elements in FETCH_ASSOC mode case-sensitive - // breaking backward-compat - //var $longreadlen = 8000; // default number of chars to return for a Blob/Long field - var $_bindInputArray = false; - var $curmode = SQL_CUR_USE_DRIVER; // See sqlext.h, SQL_CUR_DEFAULT == SQL_CUR_USE_DRIVER == 2L - var $_genSeqSQL = "create table %s (id integer)"; - var $_autocommit = true; - var $_haserrorfunctions = true; - var $_has_stupid_odbc_fetch_api_change = true; - var $_lastAffectedRows = 0; - var $uCaseTables = true; // for meta* functions, uppercase table names - - function ADODB_odbc() - { - $this->_haserrorfunctions = ADODB_PHPVER >= 0x4050; - $this->_has_stupid_odbc_fetch_api_change = ADODB_PHPVER >= 0x4200; - } - - // returns true or false - function _connect($argDSN, $argUsername, $argPassword, $argDatabasename) - { - global $php_errormsg; - - if (!function_exists('odbc_connect')) return null; - - if ($this->debug && $argDatabasename && $this->databaseType != 'vfp') { - ADOConnection::outp("For odbc Connect(), $argDatabasename is not used. Place dsn in 1st parameter."); - } - if (isset($php_errormsg)) $php_errormsg = ''; - if ($this->curmode === false) $this->_connectionID = odbc_connect($argDSN,$argUsername,$argPassword); - else $this->_connectionID = odbc_connect($argDSN,$argUsername,$argPassword,$this->curmode); - $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : ''; - if (isset($this->connectStmt)) $this->Execute($this->connectStmt); - - return $this->_connectionID != false; - } - - // returns true or false - function _pconnect($argDSN, $argUsername, $argPassword, $argDatabasename) - { - global $php_errormsg; - - if (!function_exists('odbc_connect')) return null; - - if (isset($php_errormsg)) $php_errormsg = ''; - $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : ''; - if ($this->debug && $argDatabasename) { - ADOConnection::outp("For odbc PConnect(), $argDatabasename is not used. Place dsn in 1st parameter."); - } - // print "dsn=$argDSN u=$argUsername p=$argPassword<br>"; flush(); - if ($this->curmode === false) $this->_connectionID = odbc_connect($argDSN,$argUsername,$argPassword); - else $this->_connectionID = odbc_pconnect($argDSN,$argUsername,$argPassword,$this->curmode); - - $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : ''; - if ($this->_connectionID && $this->autoRollback) @odbc_rollback($this->_connectionID); - if (isset($this->connectStmt)) $this->Execute($this->connectStmt); - - return $this->_connectionID != false; - } - - - function ServerInfo() - { - - if (!empty($this->host) && ADODB_PHPVER >= 0x4300) { - $dsn = strtoupper($this->host); - $first = true; - $found = false; - - if (!function_exists('odbc_data_source')) return false; - - while(true) { - - $rez = @odbc_data_source($this->_connectionID, - $first ? SQL_FETCH_FIRST : SQL_FETCH_NEXT); - $first = false; - if (!is_array($rez)) break; - if (strtoupper($rez['server']) == $dsn) { - $found = true; - break; - } - } - if (!$found) return ADOConnection::ServerInfo(); - if (!isset($rez['version'])) $rez['version'] = ''; - return $rez; - } else { - return ADOConnection::ServerInfo(); - } - } - - - function CreateSequence($seqname='adodbseq',$start=1) - { - if (empty($this->_genSeqSQL)) return false; - $ok = $this->Execute(sprintf($this->_genSeqSQL,$seqname)); - if (!$ok) return false; - $start -= 1; - return $this->Execute("insert into $seqname values($start)"); - } - - var $_dropSeqSQL = 'drop table %s'; - function DropSequence($seqname) - { - if (empty($this->_dropSeqSQL)) return false; - return $this->Execute(sprintf($this->_dropSeqSQL,$seqname)); - } - - /* - This algorithm is not very efficient, but works even if table locking - is not available. - - Will return false if unable to generate an ID after $MAXLOOPS attempts. - */ - function GenID($seq='adodbseq',$start=1) - { - // if you have to modify the parameter below, your database is overloaded, - // or you need to implement generation of id's yourself! - $MAXLOOPS = 100; - //$this->debug=1; - while (--$MAXLOOPS>=0) { - $num = $this->GetOne("select id from $seq"); - if ($num === false) { - $this->Execute(sprintf($this->_genSeqSQL ,$seq)); - $start -= 1; - $num = '0'; - $ok = $this->Execute("insert into $seq values($start)"); - if (!$ok) return false; - } - $this->Execute("update $seq set id=id+1 where id=$num"); - - if ($this->affected_rows() > 0) { - $num += 1; - $this->genID = $num; - return $num; - } - } - if ($fn = $this->raiseErrorFn) { - $fn($this->databaseType,'GENID',-32000,"Unable to generate unique id after $MAXLOOPS attempts",$seq,$num); - } - return false; - } - - - function ErrorMsg() - { - if ($this->_haserrorfunctions) { - if ($this->_errorMsg !== false) return $this->_errorMsg; - if (empty($this->_connectionID)) return @odbc_errormsg(); - return @odbc_errormsg($this->_connectionID); - } else return ADOConnection::ErrorMsg(); - } - - function ErrorNo() - { - - if ($this->_haserrorfunctions) { - if ($this->_errorCode !== false) { - // bug in 4.0.6, error number can be corrupted string (should be 6 digits) - return (strlen($this->_errorCode)<=2) ? 0 : $this->_errorCode; - } - - if (empty($this->_connectionID)) $e = @odbc_error(); - else $e = @odbc_error($this->_connectionID); - - // bug in 4.0.6, error number can be corrupted string (should be 6 digits) - // so we check and patch - if (strlen($e)<=2) return 0; - return $e; - } else return ADOConnection::ErrorNo(); - } - - - - function BeginTrans() - { - if (!$this->hasTransactions) return false; - if ($this->transOff) return true; - $this->transCnt += 1; - $this->_autocommit = false; - return odbc_autocommit($this->_connectionID,false); - } - - function CommitTrans($ok=true) - { - if ($this->transOff) return true; - if (!$ok) return $this->RollbackTrans(); - if ($this->transCnt) $this->transCnt -= 1; - $this->_autocommit = true; - $ret = odbc_commit($this->_connectionID); - odbc_autocommit($this->_connectionID,true); - return $ret; - } - - function RollbackTrans() - { - if ($this->transOff) return true; - if ($this->transCnt) $this->transCnt -= 1; - $this->_autocommit = true; - $ret = odbc_rollback($this->_connectionID); - odbc_autocommit($this->_connectionID,true); - return $ret; - } - - function MetaPrimaryKeys($table) - { - global $ADODB_FETCH_MODE; - - if ($this->uCaseTables) $table = strtoupper($table); - $schema = ''; - $this->_findschema($table,$schema); - - $savem = $ADODB_FETCH_MODE; - $ADODB_FETCH_MODE = ADODB_FETCH_NUM; - $qid = @odbc_primarykeys($this->_connectionID,'',$schema,$table); - - if (!$qid) { - $ADODB_FETCH_MODE = $savem; - return false; - } - $rs = new ADORecordSet_odbc($qid); - $ADODB_FETCH_MODE = $savem; - - if (!$rs) return false; - $rs->_has_stupid_odbc_fetch_api_change = $this->_has_stupid_odbc_fetch_api_change; - - $arr =& $rs->GetArray(); - $rs->Close(); - //print_r($arr); - $arr2 = array(); - for ($i=0; $i < sizeof($arr); $i++) { - if ($arr[$i][3]) $arr2[] = $arr[$i][3]; - } - return $arr2; - } - - - - function &MetaTables($ttype=false) - { - global $ADODB_FETCH_MODE; - - $savem = $ADODB_FETCH_MODE; - $ADODB_FETCH_MODE = ADODB_FETCH_NUM; - $qid = odbc_tables($this->_connectionID); - - $rs = new ADORecordSet_odbc($qid); - - $ADODB_FETCH_MODE = $savem; - if (!$rs) { - $false = false; - return $false; - } - $rs->_has_stupid_odbc_fetch_api_change = $this->_has_stupid_odbc_fetch_api_change; - - $arr =& $rs->GetArray(); - //print_r($arr); - - $rs->Close(); - $arr2 = array(); - - if ($ttype) { - $isview = strncmp($ttype,'V',1) === 0; - } - for ($i=0; $i < sizeof($arr); $i++) { - if (!$arr[$i][2]) continue; - $type = $arr[$i][3]; - if ($ttype) { - if ($isview) { - if (strncmp($type,'V',1) === 0) $arr2[] = $arr[$i][2]; - } else if (strncmp($type,'SYS',3) !== 0) $arr2[] = $arr[$i][2]; - } else if (strncmp($type,'SYS',3) !== 0) $arr2[] = $arr[$i][2]; - } - return $arr2; - } - -/* -See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcdatetime_data_type_changes.asp -/ SQL data type codes / -#define SQL_UNKNOWN_TYPE 0 -#define SQL_CHAR 1 -#define SQL_NUMERIC 2 -#define SQL_DECIMAL 3 -#define SQL_INTEGER 4 -#define SQL_SMALLINT 5 -#define SQL_FLOAT 6 -#define SQL_REAL 7 -#define SQL_DOUBLE 8 -#if (ODBCVER >= 0x0300) -#define SQL_DATETIME 9 -#endif -#define SQL_VARCHAR 12 - - -/ One-parameter shortcuts for date/time data types / -#if (ODBCVER >= 0x0300) -#define SQL_TYPE_DATE 91 -#define SQL_TYPE_TIME 92 -#define SQL_TYPE_TIMESTAMP 93 - -#define SQL_UNICODE (-95) -#define SQL_UNICODE_VARCHAR (-96) -#define SQL_UNICODE_LONGVARCHAR (-97) -*/ - function ODBCTypes($t) - { - switch ((integer)$t) { - case 1: - case 12: - case 0: - case -95: - case -96: - return 'C'; - case -97: - case -1: //text - return 'X'; - case -4: //image - return 'B'; - - case 9: - case 91: - return 'D'; - - case 10: - case 11: - case 92: - case 93: - return 'T'; - - case 4: - case 5: - case -6: - return 'I'; - - case -11: // uniqidentifier - return 'R'; - case -7: //bit - return 'L'; - - default: - return 'N'; - } - } - - function &MetaColumns($table) - { - global $ADODB_FETCH_MODE; - - $false = false; - if ($this->uCaseTables) $table = strtoupper($table); - $schema = ''; - $this->_findschema($table,$schema); - - $savem = $ADODB_FETCH_MODE; - $ADODB_FETCH_MODE = ADODB_FETCH_NUM; - - /*if (false) { // after testing, confirmed that the following does not work becoz of a bug - $qid2 = odbc_tables($this->_connectionID); - $rs = new ADORecordSet_odbc($qid2); - $ADODB_FETCH_MODE = $savem; - if (!$rs) return false; - $rs->_has_stupid_odbc_fetch_api_change = $this->_has_stupid_odbc_fetch_api_change; - $rs->_fetch(); - - while (!$rs->EOF) { - if ($table == strtoupper($rs->fields[2])) { - $q = $rs->fields[0]; - $o = $rs->fields[1]; - break; - } - $rs->MoveNext(); - } - $rs->Close(); - - $qid = odbc_columns($this->_connectionID,$q,$o,strtoupper($table),'%'); - } */ - - switch ($this->databaseType) { - case 'access': - case 'vfp': - $qid = odbc_columns($this->_connectionID);#,'%','',strtoupper($table),'%'); - break; - - - case 'db2': - $colname = "%"; - $qid = odbc_columns($this->_connectionID, "", $schema, $table, $colname); - break; - - default: - $qid = @odbc_columns($this->_connectionID,'%','%',strtoupper($table),'%'); - if (empty($qid)) $qid = odbc_columns($this->_connectionID); - break; - } - if (empty($qid)) return $false; - - $rs =& new ADORecordSet_odbc($qid); - $ADODB_FETCH_MODE = $savem; - - if (!$rs) return $false; - $rs->_has_stupid_odbc_fetch_api_change = $this->_has_stupid_odbc_fetch_api_change; - $rs->_fetch(); - - $retarr = array(); - - /* - $rs->fields indices - 0 TABLE_QUALIFIER - 1 TABLE_SCHEM - 2 TABLE_NAME - 3 COLUMN_NAME - 4 DATA_TYPE - 5 TYPE_NAME - 6 PRECISION - 7 LENGTH - 8 SCALE - 9 RADIX - 10 NULLABLE - 11 REMARKS - */ - while (!$rs->EOF) { - // adodb_pr($rs->fields); - if (strtoupper(trim($rs->fields[2])) == $table && (!$schema || strtoupper($rs->fields[1]) == $schema)) { - $fld = new ADOFieldObject(); - $fld->name = $rs->fields[3]; - $fld->type = $this->ODBCTypes($rs->fields[4]); - - // ref: http://msdn.microsoft.com/library/default.asp?url=/archive/en-us/dnaraccgen/html/msdn_odk.asp - // access uses precision to store length for char/varchar - if ($fld->type == 'C' or $fld->type == 'X') { - if ($this->databaseType == 'access') - $fld->max_length = $rs->fields[6]; - else if ($rs->fields[4] <= -95) // UNICODE - $fld->max_length = $rs->fields[7]/2; - else - $fld->max_length = $rs->fields[7]; - } else - $fld->max_length = $rs->fields[7]; - $fld->not_null = !empty($rs->fields[10]); - $fld->scale = $rs->fields[8]; - $retarr[strtoupper($fld->name)] = $fld; - } else if (sizeof($retarr)>0) - break; - $rs->MoveNext(); - } - $rs->Close(); //-- crashes 4.03pl1 -- why? - - if (empty($retarr)) $retarr = false; - return $retarr; - } - - function Prepare($sql) - { - if (! $this->_bindInputArray) return $sql; // no binding - $stmt = odbc_prepare($this->_connectionID,$sql); - if (!$stmt) { - // we don't know whether odbc driver is parsing prepared stmts, so just return sql - return $sql; - } - return array($sql,$stmt,false); - } - - /* returns queryID or false */ - function _query($sql,$inputarr=false) - { - GLOBAL $php_errormsg; - if (isset($php_errormsg)) $php_errormsg = ''; - $this->_error = ''; - - if ($inputarr) { - if (is_array($sql)) { - $stmtid = $sql[1]; - } else { - $stmtid = odbc_prepare($this->_connectionID,$sql); - - if ($stmtid == false) { - $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : ''; - return false; - } - } - - if (! odbc_execute($stmtid,$inputarr)) { - //@odbc_free_result($stmtid); - if ($this->_haserrorfunctions) { - $this->_errorMsg = odbc_errormsg(); - $this->_errorCode = odbc_error(); - } - return false; - } - - } else if (is_array($sql)) { - $stmtid = $sql[1]; - if (!odbc_execute($stmtid)) { - //@odbc_free_result($stmtid); - if ($this->_haserrorfunctions) { - $this->_errorMsg = odbc_errormsg(); - $this->_errorCode = odbc_error(); - } - return false; - } - } else - $stmtid = odbc_exec($this->_connectionID,$sql); - - $this->_lastAffectedRows = 0; - if ($stmtid) { - if (@odbc_num_fields($stmtid) == 0) { - $this->_lastAffectedRows = odbc_num_rows($stmtid); - $stmtid = true; - } else { - $this->_lastAffectedRows = 0; - odbc_binmode($stmtid,$this->binmode); - odbc_longreadlen($stmtid,$this->maxblobsize); - } - - if ($this->_haserrorfunctions) { - $this->_errorMsg = ''; - $this->_errorCode = 0; - } else - $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : ''; - } else { - if ($this->_haserrorfunctions) { - $this->_errorMsg = odbc_errormsg(); - $this->_errorCode = odbc_error(); - } else - $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : ''; - } - return $stmtid; - } - - /* - Insert a null into the blob field of the table first. - Then use UpdateBlob to store the blob. - - Usage: - - $conn->Execute('INSERT INTO blobtable (id, blobcol) VALUES (1, null)'); - $conn->UpdateBlob('blobtable','blobcol',$blob,'id=1'); - */ - function UpdateBlob($table,$column,$val,$where,$blobtype='BLOB') - { - return $this->Execute("UPDATE $table SET $column=? WHERE $where",array($val)) != false; - } - - // returns true or false - function _close() - { - $ret = @odbc_close($this->_connectionID); - $this->_connectionID = false; - return $ret; - } - - function _affectedrows() - { - return $this->_lastAffectedRows; - } - -} - -/*-------------------------------------------------------------------------------------- - Class Name: Recordset ---------------------------------------------------------------------------------------*/ - -class ADORecordSet_odbc extends ADORecordSet { - - var $bind = false; - var $databaseType = "odbc"; - var $dataProvider = "odbc"; - var $useFetchArray; - var $_has_stupid_odbc_fetch_api_change; - - function ADORecordSet_odbc($id,$mode=false) - { - if ($mode === false) { - global $ADODB_FETCH_MODE; - $mode = $ADODB_FETCH_MODE; - } - $this->fetchMode = $mode; - - $this->_queryID = $id; - - // the following is required for mysql odbc driver in 4.3.1 -- why? - $this->EOF = false; - $this->_currentRow = -1; - //$this->ADORecordSet($id); - } - - - // returns the field object - function &FetchField($fieldOffset = -1) - { - - $off=$fieldOffset+1; // offsets begin at 1 - - $o= new ADOFieldObject(); - $o->name = @odbc_field_name($this->_queryID,$off); - $o->type = @odbc_field_type($this->_queryID,$off); - $o->max_length = @odbc_field_len($this->_queryID,$off); - if (ADODB_ASSOC_CASE == 0) $o->name = strtolower($o->name); - else if (ADODB_ASSOC_CASE == 1) $o->name = strtoupper($o->name); - return $o; - } - - /* Use associative array to get fields array */ - function Fields($colname) - { - if ($this->fetchMode & ADODB_FETCH_ASSOC) return $this->fields[$colname]; - if (!$this->bind) { - $this->bind = array(); - for ($i=0; $i < $this->_numOfFields; $i++) { - $o = $this->FetchField($i); - $this->bind[strtoupper($o->name)] = $i; - } - } - - return $this->fields[$this->bind[strtoupper($colname)]]; - } - - - function _initrs() - { - global $ADODB_COUNTRECS; - $this->_numOfRows = ($ADODB_COUNTRECS) ? @odbc_num_rows($this->_queryID) : -1; - $this->_numOfFields = @odbc_num_fields($this->_queryID); - // some silly drivers such as db2 as/400 and intersystems cache return _numOfRows = 0 - if ($this->_numOfRows == 0) $this->_numOfRows = -1; - //$this->useFetchArray = $this->connection->useFetchArray; - $this->_has_stupid_odbc_fetch_api_change = ADODB_PHPVER >= 0x4200; - } - - function _seek($row) - { - return false; - } - - // speed up SelectLimit() by switching to ADODB_FETCH_NUM as ADODB_FETCH_ASSOC is emulated - function &GetArrayLimit($nrows,$offset=-1) - { - if ($offset <= 0) { - $rs =& $this->GetArray($nrows); - return $rs; - } - $savem = $this->fetchMode; - $this->fetchMode = ADODB_FETCH_NUM; - $this->Move($offset); - $this->fetchMode = $savem; - - if ($this->fetchMode & ADODB_FETCH_ASSOC) { - $this->fields =& $this->GetRowAssoc(ADODB_ASSOC_CASE); - } - - $results = array(); - $cnt = 0; - while (!$this->EOF && $nrows != $cnt) { - $results[$cnt++] = $this->fields; - $this->MoveNext(); - } - - return $results; - } - - - function MoveNext() - { - if ($this->_numOfRows != 0 && !$this->EOF) { - $this->_currentRow++; - - if ($this->_has_stupid_odbc_fetch_api_change) - $rez = @odbc_fetch_into($this->_queryID,$this->fields); - else { - $row = 0; - $rez = @odbc_fetch_into($this->_queryID,$row,$this->fields); - } - if ($rez) { - if ($this->fetchMode & ADODB_FETCH_ASSOC) { - $this->fields =& $this->GetRowAssoc(ADODB_ASSOC_CASE); - } - return true; - } - } - $this->fields = false; - $this->EOF = true; - return false; - } - - function _fetch() - { - - if ($this->_has_stupid_odbc_fetch_api_change) - $rez = @odbc_fetch_into($this->_queryID,$this->fields); - else { - $row = 0; - $rez = @odbc_fetch_into($this->_queryID,$row,$this->fields); - } - if ($rez) { - if ($this->fetchMode & ADODB_FETCH_ASSOC) { - $this->fields =& $this->GetRowAssoc(ADODB_ASSOC_CASE); - } - return true; - } - $this->fields = false; - return false; - } - - function _close() - { - return @odbc_free_result($this->_queryID); - } - -} -?>
\ No newline at end of file diff --git a/framework/3rdParty/adodb/drivers/adodb-odbc_mssql.inc.php b/framework/3rdParty/adodb/drivers/adodb-odbc_mssql.inc.php deleted file mode 100644 index e0eeff11..00000000 --- a/framework/3rdParty/adodb/drivers/adodb-odbc_mssql.inc.php +++ /dev/null @@ -1,254 +0,0 @@ -<?php -/* -V4.81 3 May 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved. - Released under both BSD license and Lesser GPL library license. - Whenever there is any discrepancy between the two licenses, - the BSD license will take precedence. -Set tabs to 4 for best viewing. - - Latest version is available at http://adodb.sourceforge.net - - MSSQL support via ODBC. Requires ODBC. Works on Windows and Unix. - For Unix configuration, see http://phpbuilder.com/columns/alberto20000919.php3 -*/ - -// security - hide paths -if (!defined('ADODB_DIR')) die(); - -if (!defined('_ADODB_ODBC_LAYER')) { - include(ADODB_DIR."/drivers/adodb-odbc.inc.php"); -} - - -class ADODB_odbc_mssql extends ADODB_odbc { - var $databaseType = 'odbc_mssql'; - var $fmtDate = "'Y-m-d'"; - var $fmtTimeStamp = "'Y-m-d H:i:s'"; - var $_bindInputArray = true; - var $metaTablesSQL="select name,case when type='U' then 'T' else 'V' end from sysobjects where (type='U' or type='V') and (name not in ('sysallocations','syscolumns','syscomments','sysdepends','sysfilegroups','sysfiles','sysfiles1','sysforeignkeys','sysfulltextcatalogs','sysindexes','sysindexkeys','sysmembers','sysobjects','syspermissions','sysprotects','sysreferences','systypes','sysusers','sysalternates','sysconstraints','syssegments','REFERENTIAL_CONSTRAINTS','CHECK_CONSTRAINTS','CONSTRAINT_TABLE_USAGE','CONSTRAINT_COLUMN_USAGE','VIEWS','VIEW_TABLE_USAGE','VIEW_COLUMN_USAGE','SCHEMATA','TABLES','TABLE_CONSTRAINTS','TABLE_PRIVILEGES','COLUMNS','COLUMN_DOMAIN_USAGE','COLUMN_PRIVILEGES','DOMAINS','DOMAIN_CONSTRAINTS','KEY_COLUMN_USAGE'))"; - var $metaColumnsSQL = "select c.name,t.name,c.length from syscolumns c join systypes t on t.xusertype=c.xusertype join sysobjects o on o.id=c.id where o.name='%s'"; - var $hasTop = 'top'; // support mssql/interbase SELECT TOP 10 * FROM TABLE - var $sysDate = 'GetDate()'; - var $sysTimeStamp = 'GetDate()'; - var $leftOuter = '*='; - var $rightOuter = '=*'; - var $substr = 'substring'; - var $length = 'len'; - var $ansiOuter = true; // for mssql7 or later - var $identitySQL = 'select @@IDENTITY'; // 'select SCOPE_IDENTITY'; # for mssql 2000 - var $hasInsertID = true; - var $connectStmt = 'SET CONCAT_NULL_YIELDS_NULL OFF'; # When SET CONCAT_NULL_YIELDS_NULL is ON, - # concatenating a null value with a string yields a NULL result - - function ADODB_odbc_mssql() - { - $this->ADODB_odbc(); - //$this->curmode = SQL_CUR_USE_ODBC; - } - - // crashes php... - function ServerInfo() - { - global $ADODB_FETCH_MODE; - $save = $ADODB_FETCH_MODE; - $ADODB_FETCH_MODE = ADODB_FETCH_NUM; - $row = $this->GetRow("execute sp_server_info 2"); - $ADODB_FETCH_MODE = $save; - if (!is_array($row)) return false; - $arr['description'] = $row[2]; - $arr['version'] = ADOConnection::_findvers($arr['description']); - return $arr; - } - - function IfNull( $field, $ifNull ) - { - return " ISNULL($field, $ifNull) "; // if MS SQL Server - } - - function _insertid() - { - // SCOPE_IDENTITY() - // Returns the last IDENTITY value inserted into an IDENTITY column in - // the same scope. A scope is a module -- a stored procedure, trigger, - // function, or batch. Thus, two statements are in the same scope if - // they are in the same stored procedure, function, or batch. - return $this->GetOne($this->identitySQL); - } - - - function MetaForeignKeys($table, $owner=false, $upper=false) - { - global $ADODB_FETCH_MODE; - - $save = $ADODB_FETCH_MODE; - $ADODB_FETCH_MODE = ADODB_FETCH_NUM; - $table = $this->qstr(strtoupper($table)); - - $sql = -"select object_name(constid) as constraint_name, - col_name(fkeyid, fkey) as column_name, - object_name(rkeyid) as referenced_table_name, - col_name(rkeyid, rkey) as referenced_column_name -from sysforeignkeys -where upper(object_name(fkeyid)) = $table -order by constraint_name, referenced_table_name, keyno"; - - $constraints =& $this->GetArray($sql); - - $ADODB_FETCH_MODE = $save; - - $arr = false; - foreach($constraints as $constr) { - //print_r($constr); - $arr[$constr[0]][$constr[2]][] = $constr[1].'='.$constr[3]; - } - if (!$arr) return false; - - $arr2 = false; - - foreach($arr as $k => $v) { - foreach($v as $a => $b) { - if ($upper) $a = strtoupper($a); - $arr2[$a] = $b; - } - } - return $arr2; - } - - function &MetaTables($ttype=false,$showSchema=false,$mask=false) - { - if ($mask) {$this->debug=1; - $save = $this->metaTablesSQL; - $mask = $this->qstr($mask); - $this->metaTablesSQL .= " AND name like $mask"; - } - $ret =& ADOConnection::MetaTables($ttype,$showSchema); - - if ($mask) { - $this->metaTablesSQL = $save; - } - return $ret; - } - - function &MetaColumns($table) - { - $arr = ADOConnection::MetaColumns($table); - return $arr; - } - - function _query($sql,$inputarr) - { - if (is_string($sql)) $sql = str_replace('||','+',$sql); - return ADODB_odbc::_query($sql,$inputarr); - } - - // "Stein-Aksel Basma" <basma@accelero.no> - // tested with MSSQL 2000 - function &MetaPrimaryKeys($table) - { - global $ADODB_FETCH_MODE; - - $schema = ''; - $this->_findschema($table,$schema); - //if (!$schema) $schema = $this->database; - if ($schema) $schema = "and k.table_catalog like '$schema%'"; - - $sql = "select distinct k.column_name,ordinal_position from information_schema.key_column_usage k, - information_schema.table_constraints tc - where tc.constraint_name = k.constraint_name and tc.constraint_type = - 'PRIMARY KEY' and k.table_name = '$table' $schema order by ordinal_position "; - - $savem = $ADODB_FETCH_MODE; - $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; - $a = $this->GetCol($sql); - $ADODB_FETCH_MODE = $savem; - - if ($a && sizeof($a)>0) return $a; - $false = false; - return $false; - } - - function &SelectLimit($sql,$nrows=-1,$offset=-1, $inputarr=false,$secs2cache=0) - { - if ($nrows > 0 && $offset <= 0) { - $sql = preg_replace( - '/(^\s*select\s+(distinctrow|distinct)?)/i','\\1 '.$this->hasTop." $nrows ",$sql); - $rs =& $this->Execute($sql,$inputarr); - } else - $rs =& ADOConnection::SelectLimit($sql,$nrows,$offset,$inputarr,$secs2cache); - - return $rs; - } - - // Format date column in sql string given an input format that understands Y M D - function SQLDate($fmt, $col=false) - { - if (!$col) $col = $this->sysTimeStamp; - $s = ''; - - $len = strlen($fmt); - for ($i=0; $i < $len; $i++) { - if ($s) $s .= '+'; - $ch = $fmt[$i]; - switch($ch) { - case 'Y': - case 'y': - $s .= "datename(yyyy,$col)"; - break; - case 'M': - $s .= "convert(char(3),$col,0)"; - break; - case 'm': - $s .= "replace(str(month($col),2),' ','0')"; - break; - case 'Q': - case 'q': - $s .= "datename(quarter,$col)"; - break; - case 'D': - case 'd': - $s .= "replace(str(day($col),2),' ','0')"; - break; - case 'h': - $s .= "substring(convert(char(14),$col,0),13,2)"; - break; - - case 'H': - $s .= "replace(str(datepart(hh,$col),2),' ','0')"; - break; - - case 'i': - $s .= "replace(str(datepart(mi,$col),2),' ','0')"; - break; - case 's': - $s .= "replace(str(datepart(ss,$col),2),' ','0')"; - break; - case 'a': - case 'A': - $s .= "substring(convert(char(19),$col,0),18,2)"; - break; - - default: - if ($ch == '\\') { - $i++; - $ch = substr($fmt,$i,1); - } - $s .= $this->qstr($ch); - break; - } - } - return $s; - } - -} - -class ADORecordSet_odbc_mssql extends ADORecordSet_odbc { - - var $databaseType = 'odbc_mssql'; - - function ADORecordSet_odbc_mssql($id,$mode=false) - { - return $this->ADORecordSet_odbc($id,$mode); - } -} -?>
\ No newline at end of file diff --git a/framework/3rdParty/adodb/drivers/adodb-odbc_oracle.inc.php b/framework/3rdParty/adodb/drivers/adodb-odbc_oracle.inc.php deleted file mode 100644 index 4cfc1bd6..00000000 --- a/framework/3rdParty/adodb/drivers/adodb-odbc_oracle.inc.php +++ /dev/null @@ -1,115 +0,0 @@ -<?php -/* -V4.81 3 May 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved. - Released under both BSD license and Lesser GPL library license. - Whenever there is any discrepancy between the two licenses, - the BSD license will take precedence. -Set tabs to 4 for best viewing. - - Latest version is available at http://adodb.sourceforge.net - - Oracle support via ODBC. Requires ODBC. Works on Windows. -*/ -// security - hide paths -if (!defined('ADODB_DIR')) die(); - -if (!defined('_ADODB_ODBC_LAYER')) { - include(ADODB_DIR."/drivers/adodb-odbc.inc.php"); -} - - -class ADODB_odbc_oracle extends ADODB_odbc { - var $databaseType = 'odbc_oracle'; - var $replaceQuote = "''"; // string to use to replace quotes - var $concat_operator='||'; - var $fmtDate = "'Y-m-d 00:00:00'"; - var $fmtTimeStamp = "'Y-m-d h:i:sA'"; - var $metaTablesSQL = 'select table_name from cat'; - var $metaColumnsSQL = "select cname,coltype,width from col where tname='%s' order by colno"; - var $sysDate = "TRUNC(SYSDATE)"; - var $sysTimeStamp = 'SYSDATE'; - - //var $_bindInputArray = false; - - function ADODB_odbc_oracle() - { - $this->ADODB_odbc(); - } - - function &MetaTables() - { - $false = false; - $rs = $this->Execute($this->metaTablesSQL); - if ($rs === false) return $false; - $arr = $rs->GetArray(); - $arr2 = array(); - for ($i=0; $i < sizeof($arr); $i++) { - $arr2[] = $arr[$i][0]; - } - $rs->Close(); - return $arr2; - } - - function &MetaColumns($table) - { - global $ADODB_FETCH_MODE; - - $rs = $this->Execute(sprintf($this->metaColumnsSQL,strtoupper($table))); - if ($rs === false) { - $false = false; - return $false; - } - $retarr = array(); - while (!$rs->EOF) { //print_r($rs->fields); - $fld = new ADOFieldObject(); - $fld->name = $rs->fields[0]; - $fld->type = $rs->fields[1]; - $fld->max_length = $rs->fields[2]; - - - if ($ADODB_FETCH_MODE == ADODB_FETCH_NUM) $retarr[] = $fld; - else $retarr[strtoupper($fld->name)] = $fld; - - $rs->MoveNext(); - } - $rs->Close(); - return $retarr; - } - - // returns true or false - function _connect($argDSN, $argUsername, $argPassword, $argDatabasename) - { - global $php_errormsg; - - $php_errormsg = ''; - $this->_connectionID = odbc_connect($argDSN,$argUsername,$argPassword,SQL_CUR_USE_ODBC ); - $this->_errorMsg = $php_errormsg; - - $this->Execute("ALTER SESSION SET NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS'"); - //if ($this->_connectionID) odbc_autocommit($this->_connectionID,true); - return $this->_connectionID != false; - } - // returns true or false - function _pconnect($argDSN, $argUsername, $argPassword, $argDatabasename) - { - global $php_errormsg; - $php_errormsg = ''; - $this->_connectionID = odbc_pconnect($argDSN,$argUsername,$argPassword,SQL_CUR_USE_ODBC ); - $this->_errorMsg = $php_errormsg; - - $this->Execute("ALTER SESSION SET NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS'"); - //if ($this->_connectionID) odbc_autocommit($this->_connectionID,true); - return $this->_connectionID != false; - } -} - -class ADORecordSet_odbc_oracle extends ADORecordSet_odbc { - - var $databaseType = 'odbc_oracle'; - - function ADORecordSet_odbc_oracle($id,$mode=false) - { - return $this->ADORecordSet_odbc($id,$mode); - } -} -?>
\ No newline at end of file diff --git a/framework/3rdParty/adodb/drivers/adodb-oracle.inc.php b/framework/3rdParty/adodb/drivers/adodb-oracle.inc.php deleted file mode 100644 index e6204f1e..00000000 --- a/framework/3rdParty/adodb/drivers/adodb-oracle.inc.php +++ /dev/null @@ -1,320 +0,0 @@ -<?php -/* -V4.81 3 May 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved. - Released under both BSD license and Lesser GPL library license. - Whenever there is any discrepancy between the two licenses, - the BSD license will take precedence. - - Latest version is available at http://adodb.sourceforge.net - - Oracle data driver. Requires Oracle client. Works on Windows and Unix and Oracle 7. - - If you are using Oracle 8 or later, use the oci8 driver which is much better and more reliable. -*/ - -// security - hide paths -if (!defined('ADODB_DIR')) die(); - -class ADODB_oracle extends ADOConnection { - var $databaseType = "oracle"; - var $replaceQuote = "''"; // string to use to replace quotes - var $concat_operator='||'; - var $_curs; - var $_initdate = true; // init date to YYYY-MM-DD - var $metaTablesSQL = 'select table_name from cat'; - var $metaColumnsSQL = "select cname,coltype,width from col where tname='%s' order by colno"; - var $sysDate = "TO_DATE(TO_CHAR(SYSDATE,'YYYY-MM-DD'),'YYYY-MM-DD')"; - var $sysTimeStamp = 'SYSDATE'; - var $connectSID = true; - - function ADODB_oracle() - { - } - - // format and return date string in database date format - function DBDate($d) - { - if (is_string($d)) $d = ADORecordSet::UnixDate($d); - return 'TO_DATE('.adodb_date($this->fmtDate,$d).",'YYYY-MM-DD')"; - } - - // format and return date string in database timestamp format - function DBTimeStamp($ts) - { - - if (is_string($ts)) $d = ADORecordSet::UnixTimeStamp($ts); - return 'TO_DATE('.adodb_date($this->fmtTimeStamp,$ts).",'RRRR-MM-DD, HH:MI:SS AM')"; - } - - - function BeginTrans() - { - $this->autoCommit = false; - ora_commitoff($this->_connectionID); - return true; - } - - - function CommitTrans($ok=true) - { - if (!$ok) return $this->RollbackTrans(); - $ret = ora_commit($this->_connectionID); - ora_commiton($this->_connectionID); - return $ret; - } - - - function RollbackTrans() - { - $ret = ora_rollback($this->_connectionID); - ora_commiton($this->_connectionID); - return $ret; - } - - - /* there seems to be a bug in the oracle extension -- always returns ORA-00000 - no error */ - function ErrorMsg() - { - if ($this->_errorMsg !== false) return $this->_errorMsg; - - if (is_resource($this->_curs)) $this->_errorMsg = @ora_error($this->_curs); - if (empty($this->_errorMsg)) $this->_errorMsg = @ora_error($this->_connectionID); - return $this->_errorMsg; - } - - - function ErrorNo() - { - if ($this->_errorCode !== false) return $this->_errorCode; - - if (is_resource($this->_curs)) $this->_errorCode = @ora_errorcode($this->_curs); - if (empty($this->_errorCode)) $this->_errorCode = @ora_errorcode($this->_connectionID); - return $this->_errorCode; - } - - - - // returns true or false - function _connect($argHostname, $argUsername, $argPassword, $argDatabasename, $mode=0) - { - if (!function_exists('ora_plogon')) return null; - - // <G. Giunta 2003/03/03/> Reset error messages before connecting - $this->_errorMsg = false; - $this->_errorCode = false; - - // G. Giunta 2003/08/13 - This looks danegrously suspicious: why should we want to set - // the oracle home to the host name of remote DB? -// if ($argHostname) putenv("ORACLE_HOME=$argHostname"); - - if($argHostname) { // code copied from version submitted for oci8 by Jorma Tuomainen <jorma.tuomainen@ppoy.fi> - if (empty($argDatabasename)) $argDatabasename = $argHostname; - else { - if(strpos($argHostname,":")) { - $argHostinfo=explode(":",$argHostname); - $argHostname=$argHostinfo[0]; - $argHostport=$argHostinfo[1]; - } else { - $argHostport="1521"; - } - - - if ($this->connectSID) { - $argDatabasename="(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=".$argHostname - .")(PORT=$argHostport))(CONNECT_DATA=(SID=$argDatabasename)))"; - } else - $argDatabasename="(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=".$argHostname - .")(PORT=$argHostport))(CONNECT_DATA=(SERVICE_NAME=$argDatabasename)))"; - } - - } - - if ($argDatabasename) $argUsername .= "@$argDatabasename"; - - //if ($argHostname) print "<p>Connect: 1st argument should be left blank for $this->databaseType</p>"; - if ($mode = 1) - $this->_connectionID = ora_plogon($argUsername,$argPassword); - else - $this->_connectionID = ora_logon($argUsername,$argPassword); - if ($this->_connectionID === false) return false; - if ($this->autoCommit) ora_commiton($this->_connectionID); - if ($this->_initdate) { - $rs = $this->_query("ALTER SESSION SET NLS_DATE_FORMAT='YYYY-MM-DD'"); - if ($rs) ora_close($rs); - } - - return true; - } - - - // returns true or false - function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename) - { - return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename, 1); - } - - - // returns query ID if successful, otherwise false - function _query($sql,$inputarr=false) - { - // <G. Giunta 2003/03/03/> Reset error messages before executing - $this->_errorMsg = false; - $this->_errorCode = false; - - $curs = ora_open($this->_connectionID); - - if ($curs === false) return false; - $this->_curs = $curs; - if (!ora_parse($curs,$sql)) return false; - if (ora_exec($curs)) return $curs; - // <G. Giunta 2004/03/03> before we close the cursor, we have to store the error message - // that we can obtain ONLY from the cursor (and not from the connection) - $this->_errorCode = @ora_errorcode($curs); - $this->_errorMsg = @ora_error($curs); - // </G. Giunta 2004/03/03> - @ora_close($curs); - return false; - } - - - // returns true or false - function _close() - { - return @ora_logoff($this->_connectionID); - } - - - -} - - -/*-------------------------------------------------------------------------------------- - Class Name: Recordset ---------------------------------------------------------------------------------------*/ - -class ADORecordset_oracle extends ADORecordSet { - - var $databaseType = "oracle"; - var $bind = false; - - function ADORecordset_oracle($queryID,$mode=false) - { - - if ($mode === false) { - global $ADODB_FETCH_MODE; - $mode = $ADODB_FETCH_MODE; - } - $this->fetchMode = $mode; - - $this->_queryID = $queryID; - - $this->_inited = true; - $this->fields = array(); - if ($queryID) { - $this->_currentRow = 0; - $this->EOF = !$this->_fetch(); - @$this->_initrs(); - } else { - $this->_numOfRows = 0; - $this->_numOfFields = 0; - $this->EOF = true; - } - - return $this->_queryID; - } - - - - /* Returns: an object containing field information. - Get column information in the Recordset object. fetchField() can be used in order to obtain information about - fields in a certain query result. If the field offset isn't specified, the next field that wasn't yet retrieved by - fetchField() is retrieved. */ - - function &FetchField($fieldOffset = -1) - { - $fld = new ADOFieldObject; - $fld->name = ora_columnname($this->_queryID, $fieldOffset); - $fld->type = ora_columntype($this->_queryID, $fieldOffset); - $fld->max_length = ora_columnsize($this->_queryID, $fieldOffset); - return $fld; - } - - /* Use associative array to get fields array */ - function Fields($colname) - { - if (!$this->bind) { - $this->bind = array(); - for ($i=0; $i < $this->_numOfFields; $i++) { - $o = $this->FetchField($i); - $this->bind[strtoupper($o->name)] = $i; - } - } - - return $this->fields[$this->bind[strtoupper($colname)]]; - } - - function _initrs() - { - $this->_numOfRows = -1; - $this->_numOfFields = @ora_numcols($this->_queryID); - } - - - function _seek($row) - { - return false; - } - - function _fetch($ignore_fields=false) { -// should remove call by reference, but ora_fetch_into requires it in 4.0.3pl1 - if ($this->fetchMode & ADODB_FETCH_ASSOC) - return @ora_fetch_into($this->_queryID,&$this->fields,ORA_FETCHINTO_NULLS|ORA_FETCHINTO_ASSOC); - else - return @ora_fetch_into($this->_queryID,&$this->fields,ORA_FETCHINTO_NULLS); - } - - /* close() only needs to be called if you are worried about using too much memory while your script - is running. All associated result memory for the specified result identifier will automatically be freed. */ - - function _close() -{ - return @ora_close($this->_queryID); - } - - function MetaType($t,$len=-1) - { - if (is_object($t)) { - $fieldobj = $t; - $t = $fieldobj->type; - $len = $fieldobj->max_length; - } - - switch (strtoupper($t)) { - case 'VARCHAR': - case 'VARCHAR2': - case 'CHAR': - case 'VARBINARY': - case 'BINARY': - if ($len <= $this->blobSize) return 'C'; - case 'LONG': - case 'LONG VARCHAR': - case 'CLOB': - return 'X'; - case 'LONG RAW': - case 'LONG VARBINARY': - case 'BLOB': - return 'B'; - - case 'DATE': return 'D'; - - //case 'T': return 'T'; - - case 'BIT': return 'L'; - case 'INT': - case 'SMALLINT': - case 'INTEGER': return 'I'; - default: return 'N'; - } - } -} -?>
\ No newline at end of file diff --git a/framework/3rdParty/adodb/drivers/adodb-pdo.inc.php b/framework/3rdParty/adodb/drivers/adodb-pdo.inc.php deleted file mode 100644 index 7d09c22d..00000000 --- a/framework/3rdParty/adodb/drivers/adodb-pdo.inc.php +++ /dev/null @@ -1,562 +0,0 @@ -<?php -/* -V4.81 3 May 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved. - Released under both BSD license and Lesser GPL library license. - Whenever there is any discrepancy between the two licenses, - the BSD license will take precedence. -Set tabs to 4 for best viewing. - - Latest version is available at http://adodb.sourceforge.net - - Requires ODBC. Works on Windows and Unix. - - Problems: - Where is float/decimal type in pdo_param_type - LOB handling for CLOB/BLOB differs significantly -*/ -// security - hide paths -if (!defined('ADODB_DIR')) die(); - - -/* -enum pdo_param_type { -PDO::PARAM_NULL, 0 - -/* int as in long (the php native int type). - * If you mark a column as an int, PDO expects get_col to return - * a pointer to a long -PDO::PARAM_INT, 1 - -/* get_col ptr should point to start of the string buffer -PDO::PARAM_STR, 2 - -/* get_col: when len is 0 ptr should point to a php_stream *, - * otherwise it should behave like a string. Indicate a NULL field - * value by setting the ptr to NULL -PDO::PARAM_LOB, 3 - -/* get_col: will expect the ptr to point to a new PDOStatement object handle, - * but this isn't wired up yet -PDO::PARAM_STMT, 4 /* hierarchical result set - -/* get_col ptr should point to a zend_bool -PDO::PARAM_BOOL, 5 - - -/* magic flag to denote a parameter as being input/output -PDO::PARAM_INPUT_OUTPUT = 0x80000000 -}; -*/ - -function adodb_pdo_type($t) -{ - switch($t) { - case 2: return 'VARCHAR'; - case 3: return 'BLOB'; - default: return 'NUMERIC'; - } -} - -/*-------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------*/ - -//////////////////////////////////////////////// - - - -class ADODB_pdo_base extends ADODB_pdo { - - var $sysDate = "'?'"; - var $sysTimeStamp = "'?'"; - - - function _init($parentDriver) - { - $parentDriver->_bindInputArray = true; - #$parentDriver->_connectionID->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY,true); - } - - function ServerInfo() - { - return ADOConnection::ServerInfo(); - } - - function SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs2cache=0) - { - $ret = ADOConnection::SelectLimit($sql,$nrows,$offset,$inputarr,$secs2cache); - return $ret; - } - - function MetaTables() - { - return false; - } - - function MetaColumns() - { - return false; - } -} - - -class ADODB_pdo extends ADOConnection { - var $databaseType = "pdo"; - var $dataProvider = "pdo"; - var $fmtDate = "'Y-m-d'"; - var $fmtTimeStamp = "'Y-m-d, h:i:sA'"; - var $replaceQuote = "''"; // string to use to replace quotes - var $hasAffectedRows = true; - var $_bindInputArray = true; - var $_genSeqSQL = "create table %s (id integer)"; - var $_autocommit = true; - var $_haserrorfunctions = true; - var $_lastAffectedRows = 0; - - var $_errormsg = false; - var $_errorno = false; - - var $dsnType = ''; - var $stmt = false; - - function ADODB_pdo() - { - } - - function _UpdatePDO() - { - $d = &$this->_driver; - $this->fmtDate = $d->fmtDate; - $this->fmtTimeStamp = $d->fmtTimeStamp; - $this->replaceQuote = $d->replaceQuote; - $this->sysDate = $d->sysDate; - $this->sysTimeStamp = $d->sysTimeStamp; - $this->random = $d->random; - $this->concat_operator = $d->concat_operator; - $this->nameQuote = $d->nameQuote; - - $d->_init($this); - } - - function Time() - { - if (!empty($this->_driver->_hasdual)) $sql = "select $this->sysTimeStamp from dual"; - else $sql = "select $this->sysTimeStamp"; - - $rs =& $this->_Execute($sql); - if ($rs && !$rs->EOF) return $this->UnixTimeStamp(reset($rs->fields)); - - return false; - } - - // returns true or false - function _connect($argDSN, $argUsername, $argPassword, $argDatabasename, $persist=false) - { - $at = strpos($argDSN,':'); - $this->dsnType = substr($argDSN,0,$at); - - if ($argDatabasename) { - $argDSN .= ';dbname='.$argDatabasename; - } - try { - $this->_connectionID = new PDO($argDSN, $argUsername, $argPassword); - } catch (Exception $e) { - $this->_connectionID = false; - $this->_errorno = -1; - //var_dump($e); - $this->_errormsg = 'Connection attempt failed: '.$e->getMessage(); - return false; - } - - if ($this->_connectionID) { - switch(ADODB_ASSOC_CASE){ - case 0: $m = PDO::CASE_LOWER; break; - case 1: $m = PDO::CASE_UPPER; break; - default: - case 2: $m = PDO::CASE_NATURAL; break; - } - - //$this->_connectionID->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_SILENT ); - $this->_connectionID->setAttribute(PDO::ATTR_CASE,$m); - - $class = 'ADODB_pdo_'.$this->dsnType; - //$this->_connectionID->setAttribute(PDO::ATTR_AUTOCOMMIT,true); - switch($this->dsnType) { - case 'oci': - case 'mysql': - case 'pgsql': - case 'mssql': - include_once(ADODB_DIR.'/drivers/adodb-pdo_'.$this->dsnType.'.inc.php'); - break; - } - if (class_exists($class)) - $this->_driver = new $class(); - else - $this->_driver = new ADODB_pdo_base(); - - $this->_driver->_connectionID = $this->_connectionID; - $this->_UpdatePDO(); - return true; - } - $this->_driver = new ADODB_pdo_base(); - return false; - } - - // returns true or false - function _pconnect($argDSN, $argUsername, $argPassword, $argDatabasename) - { - return $this->_connect($argDSN, $argUsername, $argPassword, $argDatabasename, true); - } - - /*------------------------------------------------------------------------------*/ - - - function SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs2cache=0) - { - $save = $this->_driver->fetchMode; - $this->_driver->fetchMode = $this->fetchMode; - $this->_driver->debug = $this->debug; - $ret = $this->_driver->SelectLimit($sql,$nrows,$offset,$inputarr,$secs2cache); - $this->_driver->fetchMode = $save; - return $ret; - } - - - function ServerInfo() - { - return $this->_driver->ServerInfo(); - } - - function MetaTables($ttype=false,$showSchema=false,$mask=false) - { - return $this->_driver->MetaTables($ttype,$showSchema,$mask); - } - - function MetaColumns($table,$normalize=true) - { - return $this->_driver->MetaColumns($table,$normalize); - } - - function InParameter(&$stmt,&$var,$name,$maxLen=4000,$type=false) - { - $obj = $stmt[1]; - if ($type) $obj->bindParam($name,$var,$type,$maxLen); - else $obj->bindParam($name, $var); - } - - - function ErrorMsg() - { - if ($this->_errormsg !== false) return $this->_errormsg; - if (!empty($this->_stmt)) $arr = $this->_stmt->errorInfo(); - else if (!empty($this->_connectionID)) $arr = $this->_connectionID->errorInfo(); - else return 'No Connection Established'; - - - if ($arr) { - if (sizeof($arr)<2) return ''; - if ((integer)$arr[1]) return $arr[2]; - else return ''; - } else return '-1'; - } - - - function ErrorNo() - { - if ($this->_errorno !== false) return $this->_errorno; - if (!empty($this->_stmt)) $err = $this->_stmt->errorCode(); - else if (!empty($this->_connectionID)) { - $arr = $this->_connectionID->errorInfo(); - if (isset($arr[0])) $err = $arr[0]; - else $err = -1; - } else - return 0; - - if ($err == '00000') return 0; // allows empty check - return $err; - } - - function BeginTrans() - { - if (!$this->hasTransactions) return false; - if ($this->transOff) return true; - $this->transCnt += 1; - $this->_autocommit = false; - $this->_connectionID->setAttribute(PDO::ATTR_AUTOCOMMIT,false); - return $this->_connectionID->beginTransaction(); - } - - function CommitTrans($ok=true) - { - if (!$this->hasTransactions) return false; - if ($this->transOff) return true; - if (!$ok) return $this->RollbackTrans(); - if ($this->transCnt) $this->transCnt -= 1; - $this->_autocommit = true; - - $ret = $this->_connectionID->commit(); - $this->_connectionID->setAttribute(PDO::ATTR_AUTOCOMMIT,true); - return $ret; - } - - function RollbackTrans() - { - if (!$this->hasTransactions) return false; - if ($this->transOff) return true; - if ($this->transCnt) $this->transCnt -= 1; - $this->_autocommit = true; - - $ret = $this->_connectionID->rollback(); - $this->_connectionID->setAttribute(PDO::ATTR_AUTOCOMMIT,true); - return $ret; - } - - function Prepare($sql) - { - $this->_stmt = $this->_connectionID->prepare($sql); - if ($this->_stmt) return array($sql,$this->_stmt); - - return false; - } - - function PrepareStmt($sql) - { - $stmt = $this->_connectionID->prepare($sql); - if (!$stmt) return false; - $obj = new ADOPDOStatement($stmt,$this); - return $obj; - } - - /* returns queryID or false */ - function _query($sql,$inputarr=false) - { - if (is_array($sql)) { - $stmt = $sql[1]; - } else { - $stmt = $this->_connectionID->prepare($sql); - } - - if ($stmt) { - $this->_driver->debug = $this->debug; - if ($inputarr) $ok = $stmt->execute($inputarr); - else $ok = $stmt->execute(); - } - - - $this->_errormsg = false; - $this->_errorno = false; - - if ($ok) { - $this->_stmt = $stmt; - return $stmt; - } - - if ($stmt) { - - $arr = $stmt->errorinfo(); - if ((integer)$arr[1]) { - $this->_errormsg = $arr[2]; - $this->_errorno = $arr[1]; - } - - } else { - $this->_errormsg = false; - $this->_errorno = false; - } - return false; - } - - // returns true or false - function _close() - { - $this->_stmt = false; - return true; - } - - function _affectedrows() - { - return ($this->_stmt) ? $this->_stmt->rowCount() : 0; - } - - function _insertid() - { - return ($this->_connectionID) ? $this->_connectionID->lastInsertId() : 0; - } -} - -class ADOPDOStatement { - - var $databaseType = "pdo"; - var $dataProvider = "pdo"; - var $_stmt; - var $_connectionID; - - function ADOPDOStatement($stmt,$connection) - { - $this->_stmt = $stmt; - $this->_connectionID = $connection; - } - - function Execute($inputArr=false) - { - $savestmt = $this->_connectionID->_stmt; - $rs = $this->_connectionID->Execute(array(false,$this->_stmt),$inputArr); - $this->_connectionID->_stmt = $savestmt; - return $rs; - } - - function InParameter(&$var,$name,$maxLen=4000,$type=false) - { - - if ($type) $this->_stmt->bindParam($name,$var,$type,$maxLen); - else $this->_stmt->bindParam($name, $var); - } - - function Affected_Rows() - { - return ($this->_stmt) ? $this->_stmt->rowCount() : 0; - } - - function ErrorMsg() - { - if ($this->_stmt) $arr = $this->_stmt->errorInfo(); - else $arr = $this->_connectionID->errorInfo(); - - if (is_array($arr)) { - if ((integer) $arr[0] && isset($arr[2])) return $arr[2]; - else return ''; - } else return '-1'; - } - - function NumCols() - { - return ($this->_stmt) ? $this->_stmt->columnCount() : 0; - } - - function ErrorNo() - { - if ($this->_stmt) return $this->_stmt->errorCode(); - else return $this->_connectionID->errorInfo(); - } -} - -/*-------------------------------------------------------------------------------------- - Class Name: Recordset ---------------------------------------------------------------------------------------*/ - -class ADORecordSet_pdo extends ADORecordSet { - - var $bind = false; - var $databaseType = "pdo"; - var $dataProvider = "pdo"; - - function ADORecordSet_pdo($id,$mode=false) - { - if ($mode === false) { - global $ADODB_FETCH_MODE; - $mode = $ADODB_FETCH_MODE; - } - $this->adodbFetchMode = $mode; - switch($mode) { - case ADODB_FETCH_NUM: $mode = PDO::FETCH_NUM; break; - case ADODB_FETCH_ASSOC: $mode = PDO::FETCH_ASSOC; break; - - case ADODB_FETCH_BOTH: - default: $mode = PDO::FETCH_BOTH; break; - } - $this->fetchMode = $mode; - - $this->_queryID = $id; - $this->ADORecordSet($id); - } - - - function Init() - { - if ($this->_inited) return; - $this->_inited = true; - if ($this->_queryID) @$this->_initrs(); - else { - $this->_numOfRows = 0; - $this->_numOfFields = 0; - } - if ($this->_numOfRows != 0 && $this->_currentRow == -1) { - $this->_currentRow = 0; - if ($this->EOF = ($this->_fetch() === false)) { - $this->_numOfRows = 0; // _numOfRows could be -1 - } - } else { - $this->EOF = true; - } - } - - function _initrs() - { - global $ADODB_COUNTRECS; - - $this->_numOfRows = ($ADODB_COUNTRECS) ? @$this->_queryID->rowCount() : -1; - if (!$this->_numOfRows) $this->_numOfRows = -1; - $this->_numOfFields = $this->_queryID->columnCount(); - } - - // returns the field object - function &FetchField($fieldOffset = -1) - { - $off=$fieldOffset+1; // offsets begin at 1 - - $o= new ADOFieldObject(); - $arr = @$this->_queryID->getColumnMeta($fieldOffset); - if (!$arr) { - $o->name = 'bad getColumnMeta()'; - $o->max_length = -1; - $o->type = 'VARCHAR'; - $o->precision = 0; - # $false = false; - return $o; - } - //adodb_pr($arr); - $o->name = $arr['name']; - if (isset($arr['native_type'])) $o->type = $arr['native_type']; - else $o->type = adodb_pdo_type($arr['pdo_type']); - $o->max_length = $arr['len']; - $o->precision = $arr['precision']; - - if (ADODB_ASSOC_CASE == 0) $o->name = strtolower($o->name); - else if (ADODB_ASSOC_CASE == 1) $o->name = strtoupper($o->name); - return $o; - } - - function _seek($row) - { - return false; - } - - function _fetch() - { - if (!$this->_queryID) return false; - - $this->fields = $this->_queryID->fetch($this->fetchMode); - return !empty($this->fields); - } - - function _close() - { - $this->_queryID = false; - } - - function Fields($colname) - { - if ($this->adodbFetchMode != ADODB_FETCH_NUM) return @$this->fields[$colname]; - - if (!$this->bind) { - $this->bind = array(); - for ($i=0; $i < $this->_numOfFields; $i++) { - $o = $this->FetchField($i); - $this->bind[strtoupper($o->name)] = $i; - } - } - return $this->fields[$this->bind[strtoupper($colname)]]; - } - -} - -?>
\ No newline at end of file diff --git a/framework/3rdParty/adodb/drivers/adodb-pdo_mssql.inc.php b/framework/3rdParty/adodb/drivers/adodb-pdo_mssql.inc.php deleted file mode 100644 index 850fd127..00000000 --- a/framework/3rdParty/adodb/drivers/adodb-pdo_mssql.inc.php +++ /dev/null @@ -1,50 +0,0 @@ -<?php - - -/* -V4.81 3 May 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved. - Released under both BSD license and Lesser GPL library license. - Whenever there is any discrepancy between the two licenses, - the BSD license will take precedence. - Set tabs to 8. - -*/ - -class ADODB_pdo_mssql extends ADODB_pdo { - - var $hasTop = 'top'; - var $sysDate = 'convert(datetime,convert(char,GetDate(),102),102)'; - var $sysTimeStamp = 'GetDate()'; - - - function _init($parentDriver) - { - - $parentDriver->hasTransactions = false; ## <<< BUG IN PDO mssql driver - $parentDriver->_bindInputArray = false; - $parentDriver->hasInsertID = true; - } - - function ServerInfo() - { - return ADOConnection::ServerInfo(); - } - - function SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs2cache=0) - { - $ret = ADOConnection::SelectLimit($sql,$nrows,$offset,$inputarr,$secs2cache); - return $ret; - } - - function MetaTables() - { - return false; - } - - function MetaColumns() - { - return false; - } - -} -?>
\ No newline at end of file diff --git a/framework/3rdParty/adodb/drivers/adodb-pdo_mysql.inc.php b/framework/3rdParty/adodb/drivers/adodb-pdo_mysql.inc.php deleted file mode 100644 index 3c8710b2..00000000 --- a/framework/3rdParty/adodb/drivers/adodb-pdo_mysql.inc.php +++ /dev/null @@ -1,146 +0,0 @@ -<?php - - -/* -V4.81 3 May 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved. - Released under both BSD license and Lesser GPL library license. - Whenever there is any discrepancy between the two licenses, - the BSD license will take precedence. - Set tabs to 8. - -*/ - -class ADODB_pdo_mysql extends ADODB_pdo { - var $metaTablesSQL = "SHOW TABLES"; - var $metaColumnsSQL = "SHOW COLUMNS FROM %s"; - var $_bindInputArray = false; - var $sysDate = 'CURDATE()'; - var $sysTimeStamp = 'NOW()'; - - function _init($parentDriver) - { - - $parentDriver->hasTransactions = false; - $parentDriver->_bindInputArray = true; - $parentDriver->hasInsertID = true; - $parentDriver->_connectionID->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY,true); - } - - function ServerInfo() - { - $arr['description'] = ADOConnection::GetOne("select version()"); - $arr['version'] = ADOConnection::_findvers($arr['description']); - return $arr; - } - - function &MetaTables($ttype=false,$showSchema=false,$mask=false) - { - $save = $this->metaTablesSQL; - if ($showSchema && is_string($showSchema)) { - $this->metaTablesSQL .= " from $showSchema"; - } - - if ($mask) { - $mask = $this->qstr($mask); - $this->metaTablesSQL .= " like $mask"; - } - $ret =& ADOConnection::MetaTables($ttype,$showSchema); - - $this->metaTablesSQL = $save; - return $ret; - } - - function &MetaColumns($table) - { - $this->_findschema($table,$schema); - if ($schema) { - $dbName = $this->database; - $this->SelectDB($schema); - } - global $ADODB_FETCH_MODE; - $save = $ADODB_FETCH_MODE; - $ADODB_FETCH_MODE = ADODB_FETCH_NUM; - - if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false); - $rs = $this->Execute(sprintf($this->metaColumnsSQL,$table)); - - if ($schema) { - $this->SelectDB($dbName); - } - - if (isset($savem)) $this->SetFetchMode($savem); - $ADODB_FETCH_MODE = $save; - if (!is_object($rs)) { - $false = false; - return $false; - } - - $retarr = array(); - while (!$rs->EOF){ - $fld = new ADOFieldObject(); - $fld->name = $rs->fields[0]; - $type = $rs->fields[1]; - - // split type into type(length): - $fld->scale = null; - if (preg_match("/^(.+)\((\d+),(\d+)/", $type, $query_array)) { - $fld->type = $query_array[1]; - $fld->max_length = is_numeric($query_array[2]) ? $query_array[2] : -1; - $fld->scale = is_numeric($query_array[3]) ? $query_array[3] : -1; - } elseif (preg_match("/^(.+)\((\d+)/", $type, $query_array)) { - $fld->type = $query_array[1]; - $fld->max_length = is_numeric($query_array[2]) ? $query_array[2] : -1; - } elseif (preg_match("/^(enum)\((.*)\)$/i", $type, $query_array)) { - $fld->type = $query_array[1]; - $arr = explode(",",$query_array[2]); - $fld->enums = $arr; - $zlen = max(array_map("strlen",$arr)) - 2; // PHP >= 4.0.6 - $fld->max_length = ($zlen > 0) ? $zlen : 1; - } else { - $fld->type = $type; - $fld->max_length = -1; - } - $fld->not_null = ($rs->fields[2] != 'YES'); - $fld->primary_key = ($rs->fields[3] == 'PRI'); - $fld->auto_increment = (strpos($rs->fields[5], 'auto_increment') !== false); - $fld->binary = (strpos($type,'blob') !== false); - $fld->unsigned = (strpos($type,'unsigned') !== false); - - if (!$fld->binary) { - $d = $rs->fields[4]; - if ($d != '' && $d != 'NULL') { - $fld->has_default = true; - $fld->default_value = $d; - } else { - $fld->has_default = false; - } - } - - if ($save == ADODB_FETCH_NUM) { - $retarr[] = $fld; - } else { - $retarr[strtoupper($fld->name)] = $fld; - } - $rs->MoveNext(); - } - - $rs->Close(); - return $retarr; - } - - - // parameters use PostgreSQL convention, not MySQL - function &SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs=0) - { - $offsetStr =($offset>=0) ? "$offset," : ''; - // jason judge, see http://phplens.com/lens/lensforum/msgs.php?id=9220 - if ($nrows < 0) $nrows = '18446744073709551615'; - - if ($secs) - $rs =& $this->CacheExecute($secs,$sql." LIMIT $offsetStr$nrows",$inputarr); - else - $rs =& $this->Execute($sql." LIMIT $offsetStr$nrows",$inputarr); - return $rs; - } -} -?>
\ No newline at end of file diff --git a/framework/3rdParty/adodb/drivers/adodb-pdo_oci.inc.php b/framework/3rdParty/adodb/drivers/adodb-pdo_oci.inc.php deleted file mode 100644 index 80665657..00000000 --- a/framework/3rdParty/adodb/drivers/adodb-pdo_oci.inc.php +++ /dev/null @@ -1,93 +0,0 @@ -<?php - - -/* -V4.81 3 May 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved. - Released under both BSD license and Lesser GPL library license. - Whenever there is any discrepancy between the two licenses, - the BSD license will take precedence. - Set tabs to 8. - -*/ - -class ADODB_pdo_oci extends ADODB_pdo_base { - - var $concat_operator='||'; - var $sysDate = "TRUNC(SYSDATE)"; - var $sysTimeStamp = 'SYSDATE'; - var $NLS_DATE_FORMAT = 'YYYY-MM-DD'; // To include time, use 'RRRR-MM-DD HH24:MI:SS' - var $random = "abs(mod(DBMS_RANDOM.RANDOM,10000001)/10000000)"; - var $metaTablesSQL = "select table_name,table_type from cat where table_type in ('TABLE','VIEW')"; - var $metaColumnsSQL = "select cname,coltype,width, SCALE, PRECISION, NULLS, DEFAULTVAL from col where tname='%s' order by colno"; - - var $_initdate = true; - var $_hasdual = true; - - function _init($parentDriver) - { - $parentDriver->_bindInputArray = true; - - if ($this->_initdate) { - $parentDriver->Execute("ALTER SESSION SET NLS_DATE_FORMAT='".$this->NLS_DATE_FORMAT."'"); - } - } - - function &MetaTables($ttype=false,$showSchema=false,$mask=false) - { - if ($mask) { - $save = $this->metaTablesSQL; - $mask = $this->qstr(strtoupper($mask)); - $this->metaTablesSQL .= " AND table_name like $mask"; - } - $ret =& ADOConnection::MetaTables($ttype,$showSchema); - - if ($mask) { - $this->metaTablesSQL = $save; - } - return $ret; - } - - function &MetaColumns($table) - { - global $ADODB_FETCH_MODE; - - $false = false; - $save = $ADODB_FETCH_MODE; - $ADODB_FETCH_MODE = ADODB_FETCH_NUM; - if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false); - - $rs = $this->Execute(sprintf($this->metaColumnsSQL,strtoupper($table))); - - if (isset($savem)) $this->SetFetchMode($savem); - $ADODB_FETCH_MODE = $save; - if (!$rs) { - return $false; - } - $retarr = array(); - while (!$rs->EOF) { //print_r($rs->fields); - $fld = new ADOFieldObject(); - $fld->name = $rs->fields[0]; - $fld->type = $rs->fields[1]; - $fld->max_length = $rs->fields[2]; - $fld->scale = $rs->fields[3]; - if ($rs->fields[1] == 'NUMBER' && $rs->fields[3] == 0) { - $fld->type ='INT'; - $fld->max_length = $rs->fields[4]; - } - $fld->not_null = (strncmp($rs->fields[5], 'NOT',3) === 0); - $fld->binary = (strpos($fld->type,'BLOB') !== false); - $fld->default_value = $rs->fields[6]; - - if ($ADODB_FETCH_MODE == ADODB_FETCH_NUM) $retarr[] = $fld; - else $retarr[strtoupper($fld->name)] = $fld; - $rs->MoveNext(); - } - $rs->Close(); - if (empty($retarr)) - return $false; - else - return $retarr; - } -} - -?>
\ No newline at end of file diff --git a/framework/3rdParty/adodb/drivers/adodb-pdo_pgsql.inc.php b/framework/3rdParty/adodb/drivers/adodb-pdo_pgsql.inc.php deleted file mode 100644 index 2de50364..00000000 --- a/framework/3rdParty/adodb/drivers/adodb-pdo_pgsql.inc.php +++ /dev/null @@ -1,229 +0,0 @@ -<?php - -/* -V4.81 3 May 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved. - Released under both BSD license and Lesser GPL library license. - Whenever there is any discrepancy between the two licenses, - the BSD license will take precedence. - Set tabs to 8. - -*/ - -class ADODB_pdo_pgsql extends ADODB_pdo { - var $metaDatabasesSQL = "select datname from pg_database where datname not in ('template0','template1') order by 1"; - var $metaTablesSQL = "select tablename,'T' from pg_tables where tablename not like 'pg\_%' - and tablename not in ('sql_features', 'sql_implementation_info', 'sql_languages', - 'sql_packages', 'sql_sizing', 'sql_sizing_profiles') - union - select viewname,'V' from pg_views where viewname not like 'pg\_%'"; - //"select tablename from pg_tables where tablename not like 'pg_%' order by 1"; - var $isoDates = true; // accepts dates in ISO format - var $sysDate = "CURRENT_DATE"; - var $sysTimeStamp = "CURRENT_TIMESTAMP"; - var $blobEncodeType = 'C'; - var $metaColumnsSQL = "SELECT a.attname,t.typname,a.attlen,a.atttypmod,a.attnotnull,a.atthasdef,a.attnum - FROM pg_class c, pg_attribute a,pg_type t - WHERE relkind in ('r','v') AND (c.relname='%s' or c.relname = lower('%s')) and a.attname not like '....%%' -AND a.attnum > 0 AND a.atttypid = t.oid AND a.attrelid = c.oid ORDER BY a.attnum"; - - // used when schema defined - var $metaColumnsSQL1 = "SELECT a.attname, t.typname, a.attlen, a.atttypmod, a.attnotnull, a.atthasdef, a.attnum -FROM pg_class c, pg_attribute a, pg_type t, pg_namespace n -WHERE relkind in ('r','v') AND (c.relname='%s' or c.relname = lower('%s')) - and c.relnamespace=n.oid and n.nspname='%s' - and a.attname not like '....%%' AND a.attnum > 0 - AND a.atttypid = t.oid AND a.attrelid = c.oid ORDER BY a.attnum"; - - // get primary key etc -- from Freek Dijkstra - var $metaKeySQL = "SELECT ic.relname AS index_name, a.attname AS column_name,i.indisunique AS unique_key, i.indisprimary AS primary_key - FROM pg_class bc, pg_class ic, pg_index i, pg_attribute a WHERE bc.oid = i.indrelid AND ic.oid = i.indexrelid AND (i.indkey[0] = a.attnum OR i.indkey[1] = a.attnum OR i.indkey[2] = a.attnum OR i.indkey[3] = a.attnum OR i.indkey[4] = a.attnum OR i.indkey[5] = a.attnum OR i.indkey[6] = a.attnum OR i.indkey[7] = a.attnum) AND a.attrelid = bc.oid AND bc.relname = '%s'"; - - var $hasAffectedRows = true; - var $hasLimit = false; // set to true for pgsql 7 only. support pgsql/mysql SELECT * FROM TABLE LIMIT 10 - // below suggested by Freek Dijkstra - var $true = 't'; // string that represents TRUE for a database - var $false = 'f'; // string that represents FALSE for a database - var $fmtDate = "'Y-m-d'"; // used by DBDate() as the default date format used by the database - var $fmtTimeStamp = "'Y-m-d G:i:s'"; // used by DBTimeStamp as the default timestamp fmt. - var $hasMoveFirst = true; - var $hasGenID = true; - var $_genIDSQL = "SELECT NEXTVAL('%s')"; - var $_genSeqSQL = "CREATE SEQUENCE %s START %s"; - var $_dropSeqSQL = "DROP SEQUENCE %s"; - var $metaDefaultsSQL = "SELECT d.adnum as num, d.adsrc as def from pg_attrdef d, pg_class c where d.adrelid=c.oid and c.relname='%s' order by d.adnum"; - var $random = 'random()'; /// random function - var $concat_operator='||'; - - function _init($parentDriver) - { - - $parentDriver->hasTransactions = false; ## <<< BUG IN PDO pgsql driver - $parentDriver->hasInsertID = true; - } - - function ServerInfo() - { - $arr['description'] = ADOConnection::GetOne("select version()"); - $arr['version'] = ADOConnection::_findvers($arr['description']); - return $arr; - } - - function &SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs2cache=0) - { - $offsetStr = ($offset >= 0) ? " OFFSET $offset" : ''; - $limitStr = ($nrows >= 0) ? " LIMIT $nrows" : ''; - if ($secs2cache) - $rs =& $this->CacheExecute($secs2cache,$sql."$limitStr$offsetStr",$inputarr); - else - $rs =& $this->Execute($sql."$limitStr$offsetStr",$inputarr); - - return $rs; - } - - function &MetaTables($ttype=false,$showSchema=false,$mask=false) - { - $info = $this->ServerInfo(); - if ($info['version'] >= 7.3) { - $this->metaTablesSQL = "select tablename,'T' from pg_tables where tablename not like 'pg\_%' - and schemaname not in ( 'pg_catalog','information_schema') - union - select viewname,'V' from pg_views where viewname not like 'pg\_%' and schemaname not in ( 'pg_catalog','information_schema') "; - } - if ($mask) { - $save = $this->metaTablesSQL; - $mask = $this->qstr(strtolower($mask)); - if ($info['version']>=7.3) - $this->metaTablesSQL = " -select tablename,'T' from pg_tables where tablename like $mask and schemaname not in ( 'pg_catalog','information_schema') - union -select viewname,'V' from pg_views where viewname like $mask and schemaname not in ( 'pg_catalog','information_schema') "; - else - $this->metaTablesSQL = " -select tablename,'T' from pg_tables where tablename like $mask - union -select viewname,'V' from pg_views where viewname like $mask"; - } - $ret =& ADOConnection::MetaTables($ttype,$showSchema); - - if ($mask) { - $this->metaTablesSQL = $save; - } - return $ret; - } - - function &MetaColumns($table,$normalize=true) - { - global $ADODB_FETCH_MODE; - - $schema = false; - $this->_findschema($table,$schema); - - if ($normalize) $table = strtolower($table); - - $save = $ADODB_FETCH_MODE; - $ADODB_FETCH_MODE = ADODB_FETCH_NUM; - if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false); - - if ($schema) $rs =& $this->Execute(sprintf($this->metaColumnsSQL1,$table,$table,$schema)); - else $rs =& $this->Execute(sprintf($this->metaColumnsSQL,$table,$table)); - if (isset($savem)) $this->SetFetchMode($savem); - $ADODB_FETCH_MODE = $save; - - if ($rs === false) { - $false = false; - return $false; - } - if (!empty($this->metaKeySQL)) { - // If we want the primary keys, we have to issue a separate query - // Of course, a modified version of the metaColumnsSQL query using a - // LEFT JOIN would have been much more elegant, but postgres does - // not support OUTER JOINS. So here is the clumsy way. - - $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; - - $rskey = $this->Execute(sprintf($this->metaKeySQL,($table))); - // fetch all result in once for performance. - $keys =& $rskey->GetArray(); - if (isset($savem)) $this->SetFetchMode($savem); - $ADODB_FETCH_MODE = $save; - - $rskey->Close(); - unset($rskey); - } - - $rsdefa = array(); - if (!empty($this->metaDefaultsSQL)) { - $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; - $sql = sprintf($this->metaDefaultsSQL, ($table)); - $rsdef = $this->Execute($sql); - if (isset($savem)) $this->SetFetchMode($savem); - $ADODB_FETCH_MODE = $save; - - if ($rsdef) { - while (!$rsdef->EOF) { - $num = $rsdef->fields['num']; - $s = $rsdef->fields['def']; - if (strpos($s,'::')===false && substr($s, 0, 1) == "'") { /* quoted strings hack... for now... fixme */ - $s = substr($s, 1); - $s = substr($s, 0, strlen($s) - 1); - } - - $rsdefa[$num] = $s; - $rsdef->MoveNext(); - } - } else { - ADOConnection::outp( "==> SQL => " . $sql); - } - unset($rsdef); - } - - $retarr = array(); - while (!$rs->EOF) { - $fld = new ADOFieldObject(); - $fld->name = $rs->fields[0]; - $fld->type = $rs->fields[1]; - $fld->max_length = $rs->fields[2]; - if ($fld->max_length <= 0) $fld->max_length = $rs->fields[3]-4; - if ($fld->max_length <= 0) $fld->max_length = -1; - if ($fld->type == 'numeric') { - $fld->scale = $fld->max_length & 0xFFFF; - $fld->max_length >>= 16; - } - // dannym - // 5 hasdefault; 6 num-of-column - $fld->has_default = ($rs->fields[5] == 't'); - if ($fld->has_default) { - $fld->default_value = $rsdefa[$rs->fields[6]]; - } - - //Freek - if ($rs->fields[4] == $this->true) { - $fld->not_null = true; - } - - // Freek - if (is_array($keys)) { - foreach($keys as $key) { - if ($fld->name == $key['column_name'] AND $key['primary_key'] == $this->true) - $fld->primary_key = true; - if ($fld->name == $key['column_name'] AND $key['unique_key'] == $this->true) - $fld->unique = true; // What name is more compatible? - } - } - - if ($ADODB_FETCH_MODE == ADODB_FETCH_NUM) $retarr[] = $fld; - else $retarr[($normalize) ? strtoupper($fld->name) : $fld->name] = $fld; - - $rs->MoveNext(); - } - $rs->Close(); - if (empty($retarr)) { - $false = false; - return $false; - } else return $retarr; - - } - -} - -?> diff --git a/framework/3rdParty/adodb/drivers/adodb-postgres64.inc.php b/framework/3rdParty/adodb/drivers/adodb-postgres64.inc.php deleted file mode 100644 index feadbaa9..00000000 --- a/framework/3rdParty/adodb/drivers/adodb-postgres64.inc.php +++ /dev/null @@ -1,1047 +0,0 @@ -<?php -/* - V4.81 3 May 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved. - Released under both BSD license and Lesser GPL library license. - Whenever there is any discrepancy between the two licenses, - the BSD license will take precedence. - Set tabs to 8. - - Original version derived from Alberto Cerezal (acerezalp@dbnet.es) - DBNet Informatica & Comunicaciones. - 08 Nov 2000 jlim - Minor corrections, removing mysql stuff - 09 Nov 2000 jlim - added insertid support suggested by "Christopher Kings-Lynne" <chriskl@familyhealth.com.au> - jlim - changed concat operator to || and data types to MetaType to match documented pgsql types - see http://www.postgresql.org/devel-corner/docs/postgres/datatype.htm - 22 Nov 2000 jlim - added changes to FetchField() and MetaTables() contributed by "raser" <raser@mail.zen.com.tw> - 27 Nov 2000 jlim - added changes to _connect/_pconnect from ideas by "Lennie" <leen@wirehub.nl> - 15 Dec 2000 jlim - added changes suggested by Additional code changes by "Eric G. Werk" egw@netguide.dk. - 31 Jan 2002 jlim - finally installed postgresql. testing - 01 Mar 2001 jlim - Freek Dijkstra changes, also support for text type - - See http://www.varlena.com/varlena/GeneralBits/47.php - - -- What indexes are on my table? - select * from pg_indexes where tablename = 'tablename'; - - -- What triggers are on my table? - select c.relname as "Table", t.tgname as "Trigger Name", - t.tgconstrname as "Constraint Name", t.tgenabled as "Enabled", - t.tgisconstraint as "Is Constraint", cc.relname as "Referenced Table", - p.proname as "Function Name" - from pg_trigger t, pg_class c, pg_class cc, pg_proc p - where t.tgfoid = p.oid and t.tgrelid = c.oid - and t.tgconstrrelid = cc.oid - and c.relname = 'tablename'; - - -- What constraints are on my table? - select r.relname as "Table", c.conname as "Constraint Name", - contype as "Constraint Type", conkey as "Key Columns", - confkey as "Foreign Columns", consrc as "Source" - from pg_class r, pg_constraint c - where r.oid = c.conrelid - and relname = 'tablename'; - -*/ - -// security - hide paths -if (!defined('ADODB_DIR')) die(); - -function adodb_addslashes($s) -{ - $len = strlen($s); - if ($len == 0) return "''"; - if (strncmp($s,"'",1) === 0 && substr($s,$len-1) == "'") return $s; // already quoted - - return "'".addslashes($s)."'"; -} - -class ADODB_postgres64 extends ADOConnection{ - var $databaseType = 'postgres64'; - var $dataProvider = 'postgres'; - var $hasInsertID = true; - var $_resultid = false; - var $concat_operator='||'; - var $metaDatabasesSQL = "select datname from pg_database where datname not in ('template0','template1') order by 1"; - var $metaTablesSQL = "select tablename,'T' from pg_tables where tablename not like 'pg\_%' - and tablename not in ('sql_features', 'sql_implementation_info', 'sql_languages', - 'sql_packages', 'sql_sizing', 'sql_sizing_profiles') - union - select viewname,'V' from pg_views where viewname not like 'pg\_%'"; - //"select tablename from pg_tables where tablename not like 'pg_%' order by 1"; - var $isoDates = true; // accepts dates in ISO format - var $sysDate = "CURRENT_DATE"; - var $sysTimeStamp = "CURRENT_TIMESTAMP"; - var $blobEncodeType = 'C'; - var $metaColumnsSQL = "SELECT a.attname,t.typname,a.attlen,a.atttypmod,a.attnotnull,a.atthasdef,a.attnum - FROM pg_class c, pg_attribute a,pg_type t - WHERE relkind in ('r','v') AND (c.relname='%s' or c.relname = lower('%s')) and a.attname not like '....%%' -AND a.attnum > 0 AND a.atttypid = t.oid AND a.attrelid = c.oid ORDER BY a.attnum"; - - // used when schema defined - var $metaColumnsSQL1 = "SELECT a.attname, t.typname, a.attlen, a.atttypmod, a.attnotnull, a.atthasdef, a.attnum -FROM pg_class c, pg_attribute a, pg_type t, pg_namespace n -WHERE relkind in ('r','v') AND (c.relname='%s' or c.relname = lower('%s')) - and c.relnamespace=n.oid and n.nspname='%s' - and a.attname not like '....%%' AND a.attnum > 0 - AND a.atttypid = t.oid AND a.attrelid = c.oid ORDER BY a.attnum"; - - // get primary key etc -- from Freek Dijkstra - var $metaKeySQL = "SELECT ic.relname AS index_name, a.attname AS column_name,i.indisunique AS unique_key, i.indisprimary AS primary_key - FROM pg_class bc, pg_class ic, pg_index i, pg_attribute a WHERE bc.oid = i.indrelid AND ic.oid = i.indexrelid AND (i.indkey[0] = a.attnum OR i.indkey[1] = a.attnum OR i.indkey[2] = a.attnum OR i.indkey[3] = a.attnum OR i.indkey[4] = a.attnum OR i.indkey[5] = a.attnum OR i.indkey[6] = a.attnum OR i.indkey[7] = a.attnum) AND a.attrelid = bc.oid AND bc.relname = '%s'"; - - var $hasAffectedRows = true; - var $hasLimit = false; // set to true for pgsql 7 only. support pgsql/mysql SELECT * FROM TABLE LIMIT 10 - // below suggested by Freek Dijkstra - var $true = 'TRUE'; // string that represents TRUE for a database - var $false = 'FALSE'; // string that represents FALSE for a database - var $fmtDate = "'Y-m-d'"; // used by DBDate() as the default date format used by the database - var $fmtTimeStamp = "'Y-m-d H:i:s'"; // used by DBTimeStamp as the default timestamp fmt. - var $hasMoveFirst = true; - var $hasGenID = true; - var $_genIDSQL = "SELECT NEXTVAL('%s')"; - var $_genSeqSQL = "CREATE SEQUENCE %s START %s"; - var $_dropSeqSQL = "DROP SEQUENCE %s"; - var $metaDefaultsSQL = "SELECT d.adnum as num, d.adsrc as def from pg_attrdef d, pg_class c where d.adrelid=c.oid and c.relname='%s' order by d.adnum"; - var $random = 'random()'; /// random function - var $autoRollback = true; // apparently pgsql does not autorollback properly before php 4.3.4 - // http://bugs.php.net/bug.php?id=25404 - - var $_bindInputArray = false; // requires postgresql 7.3+ and ability to modify database - var $disableBlobs = false; // set to true to disable blob checking, resulting in 2-5% improvement in performance. - - // The last (fmtTimeStamp is not entirely correct: - // PostgreSQL also has support for time zones, - // and writes these time in this format: "2001-03-01 18:59:26+02". - // There is no code for the "+02" time zone information, so I just left that out. - // I'm not familiar enough with both ADODB as well as Postgres - // to know what the concequences are. The other values are correct (wheren't in 0.94) - // -- Freek Dijkstra - - function ADODB_postgres64() - { - // changes the metaColumnsSQL, adds columns: attnum[6] - } - - function ServerInfo() - { - if (isset($this->version)) return $this->version; - - $arr['description'] = $this->GetOne("select version()"); - $arr['version'] = ADOConnection::_findvers($arr['description']); - $this->version = $arr; - return $arr; - } - - function IfNull( $field, $ifNull ) - { - return " coalesce($field, $ifNull) "; - } - - // get the last id - never tested - function pg_insert_id($tablename,$fieldname) - { - $result=pg_exec($this->_connectionID, "SELECT last_value FROM ${tablename}_${fieldname}_seq"); - if ($result) { - $arr = @pg_fetch_row($result,0); - pg_freeresult($result); - if (isset($arr[0])) return $arr[0]; - } - return false; - } - -/* Warning from http://www.php.net/manual/function.pg-getlastoid.php: -Using a OID as a unique identifier is not generally wise. -Unless you are very careful, you might end up with a tuple having -a different OID if a database must be reloaded. */ - function _insertid($table,$column) - { - if (!is_resource($this->_resultid) || get_resource_type($this->_resultid) !== 'pgsql result') return false; - $oid = pg_getlastoid($this->_resultid); - // to really return the id, we need the table and column-name, else we can only return the oid != id - return empty($table) || empty($column) ? $oid : $this->GetOne("SELECT $column FROM $table WHERE oid=".(int)$oid); - } - -// I get this error with PHP before 4.0.6 - jlim -// Warning: This compilation does not support pg_cmdtuples() in adodb-postgres.inc.php on line 44 - function _affectedrows() - { - if (!is_resource($this->_resultid) || get_resource_type($this->_resultid) !== 'pgsql result') return false; - return pg_cmdtuples($this->_resultid); - } - - - // returns true/false - function BeginTrans() - { - if ($this->transOff) return true; - $this->transCnt += 1; - return @pg_Exec($this->_connectionID, "begin"); - } - - function RowLock($tables,$where,$flds='1 as ignore') - { - if (!$this->transCnt) $this->BeginTrans(); - return $this->GetOne("select $flds from $tables where $where for update"); - } - - // returns true/false. - function CommitTrans($ok=true) - { - if ($this->transOff) return true; - if (!$ok) return $this->RollbackTrans(); - - $this->transCnt -= 1; - return @pg_Exec($this->_connectionID, "commit"); - } - - // returns true/false - function RollbackTrans() - { - if ($this->transOff) return true; - $this->transCnt -= 1; - return @pg_Exec($this->_connectionID, "rollback"); - } - - function &MetaTables($ttype=false,$showSchema=false,$mask=false) - { - $info = $this->ServerInfo(); - if ($info['version'] >= 7.3) { - $this->metaTablesSQL = "select tablename,'T' from pg_tables where tablename not like 'pg\_%' - and schemaname not in ( 'pg_catalog','information_schema') - union - select viewname,'V' from pg_views where viewname not like 'pg\_%' and schemaname not in ( 'pg_catalog','information_schema') "; - } - if ($mask) { - $save = $this->metaTablesSQL; - $mask = $this->qstr(strtolower($mask)); - if ($info['version']>=7.3) - $this->metaTablesSQL = " -select tablename,'T' from pg_tables where tablename like $mask and schemaname not in ( 'pg_catalog','information_schema') - union -select viewname,'V' from pg_views where viewname like $mask and schemaname not in ( 'pg_catalog','information_schema') "; - else - $this->metaTablesSQL = " -select tablename,'T' from pg_tables where tablename like $mask - union -select viewname,'V' from pg_views where viewname like $mask"; - } - $ret =& ADOConnection::MetaTables($ttype,$showSchema); - - if ($mask) { - $this->metaTablesSQL = $save; - } - return $ret; - } - - - // if magic quotes disabled, use pg_escape_string() - function qstr($s,$magic_quotes=false) - { - if (!$magic_quotes) { - if (ADODB_PHPVER >= 0x4200) { - return "'".pg_escape_string($s)."'"; - } - if ($this->replaceQuote[0] == '\\'){ - $s = adodb_str_replace(array('\\',"\0"),array('\\\\',"\\\\000"),$s); - } - return "'".str_replace("'",$this->replaceQuote,$s)."'"; - } - - // undo magic quotes for " - $s = str_replace('\\"','"',$s); - return "'$s'"; - } - - - - // Format date column in sql string given an input format that understands Y M D - function SQLDate($fmt, $col=false) - { - if (!$col) $col = $this->sysTimeStamp; - $s = 'TO_CHAR('.$col.",'"; - - $len = strlen($fmt); - for ($i=0; $i < $len; $i++) { - $ch = $fmt[$i]; - switch($ch) { - case 'Y': - case 'y': - $s .= 'YYYY'; - break; - case 'Q': - case 'q': - $s .= 'Q'; - break; - - case 'M': - $s .= 'Mon'; - break; - - case 'm': - $s .= 'MM'; - break; - case 'D': - case 'd': - $s .= 'DD'; - break; - - case 'H': - $s.= 'HH24'; - break; - - case 'h': - $s .= 'HH'; - break; - - case 'i': - $s .= 'MI'; - break; - - case 's': - $s .= 'SS'; - break; - - case 'a': - case 'A': - $s .= 'AM'; - break; - - case 'w': - $s .= 'D'; - break; - - case 'l': - $s .= 'DAY'; - break; - - case 'W': - $s .= 'WW'; - break; - - default: - // handle escape characters... - if ($ch == '\\') { - $i++; - $ch = substr($fmt,$i,1); - } - if (strpos('-/.:;, ',$ch) !== false) $s .= $ch; - else $s .= '"'.$ch.'"'; - - } - } - return $s. "')"; - } - - - - /* - * Load a Large Object from a file - * - the procedure stores the object id in the table and imports the object using - * postgres proprietary blob handling routines - * - * contributed by Mattia Rossi mattia@technologist.com - * modified for safe mode by juraj chlebec - */ - function UpdateBlobFile($table,$column,$path,$where,$blobtype='BLOB') - { - pg_exec ($this->_connectionID, "begin"); - - $fd = fopen($path,'r'); - $contents = fread($fd,filesize($path)); - fclose($fd); - - $oid = pg_lo_create($this->_connectionID); - $handle = pg_lo_open($this->_connectionID, $oid, 'w'); - pg_lo_write($handle, $contents); - pg_lo_close($handle); - - // $oid = pg_lo_import ($path); - pg_exec($this->_connectionID, "commit"); - $rs = ADOConnection::UpdateBlob($table,$column,$oid,$where,$blobtype); - $rez = !empty($rs); - return $rez; - } - - /* - * Deletes/Unlinks a Blob from the database, otherwise it - * will be left behind - * - * Returns TRUE on success or FALSE on failure. - * - * contributed by Todd Rogers todd#windfox.net - */ - function BlobDelete( $blob ) - { - pg_exec ($this->_connectionID, "begin"); - $result = @pg_lo_unlink($blob); - pg_exec ($this->_connectionID, "commit"); - return( $result ); - } - - /* - Hueristic - not guaranteed to work. - */ - function GuessOID($oid) - { - if (strlen($oid)>16) return false; - return is_numeric($oid); - } - - /* - * If an OID is detected, then we use pg_lo_* to open the oid file and read the - * real blob from the db using the oid supplied as a parameter. If you are storing - * blobs using bytea, we autodetect and process it so this function is not needed. - * - * contributed by Mattia Rossi mattia@technologist.com - * - * see http://www.postgresql.org/idocs/index.php?largeobjects.html - * - * Since adodb 4.54, this returns the blob, instead of sending it to stdout. Also - * added maxsize parameter, which defaults to $db->maxblobsize if not defined. - */ - function BlobDecode($blob,$maxsize=false,$hastrans=true) - { - if (!$this->GuessOID($blob)) return $blob; - - if ($hastrans) @pg_exec($this->_connectionID,"begin"); - $fd = @pg_lo_open($this->_connectionID,$blob,"r"); - if ($fd === false) { - if ($hastrans) @pg_exec($this->_connectionID,"commit"); - return $blob; - } - if (!$maxsize) $maxsize = $this->maxblobsize; - $realblob = @pg_loread($fd,$maxsize); - @pg_loclose($fd); - if ($hastrans) @pg_exec($this->_connectionID,"commit"); - return $realblob; - } - - /* - See http://www.postgresql.org/idocs/index.php?datatype-binary.html - - NOTE: SQL string literals (input strings) must be preceded with two backslashes - due to the fact that they must pass through two parsers in the PostgreSQL - backend. - */ - function BlobEncode($blob) - { - if (ADODB_PHPVER >= 0x4200) return pg_escape_bytea($blob); - - /*92=backslash, 0=null, 39=single-quote*/ - $badch = array(chr(92),chr(0),chr(39)); # \ null ' - $fixch = array('\\\\134','\\\\000','\\\\047'); - return adodb_str_replace($badch,$fixch,$blob); - - // note that there is a pg_escape_bytea function only for php 4.2.0 or later - } - - // assumes bytea for blob, and varchar for clob - function UpdateBlob($table,$column,$val,$where,$blobtype='BLOB') - { - - if ($blobtype == 'CLOB') { - return $this->Execute("UPDATE $table SET $column=" . $this->qstr($val) . " WHERE $where"); - } - // do not use bind params which uses qstr(), as blobencode() already quotes data - return $this->Execute("UPDATE $table SET $column='".$this->BlobEncode($val)."'::bytea WHERE $where"); - } - - function OffsetDate($dayFraction,$date=false) - { - if (!$date) $date = $this->sysDate; - else if (strncmp($date,"'",1) == 0) { - $len = strlen($date); - if (10 <= $len && $len <= 12) $date = 'date '.$date; - else $date = 'timestamp '.$date; - } - return "($date+interval'$dayFraction days')"; - } - - - // for schema support, pass in the $table param "$schema.$tabname". - // converts field names to lowercase, $upper is ignored - // see http://phplens.com/lens/lensforum/msgs.php?id=14018 for more info - function &MetaColumns($table,$normalize=true) - { - global $ADODB_FETCH_MODE; - - $schema = false; - $false = false; - $this->_findschema($table,$schema); - - if ($normalize) $table = strtolower($table); - - $save = $ADODB_FETCH_MODE; - $ADODB_FETCH_MODE = ADODB_FETCH_NUM; - if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false); - - if ($schema) $rs =& $this->Execute(sprintf($this->metaColumnsSQL1,$table,$table,$schema)); - else $rs =& $this->Execute(sprintf($this->metaColumnsSQL,$table,$table)); - if (isset($savem)) $this->SetFetchMode($savem); - $ADODB_FETCH_MODE = $save; - - if ($rs === false) { - return $false; - } - if (!empty($this->metaKeySQL)) { - // If we want the primary keys, we have to issue a separate query - // Of course, a modified version of the metaColumnsSQL query using a - // LEFT JOIN would have been much more elegant, but postgres does - // not support OUTER JOINS. So here is the clumsy way. - - $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; - - $rskey = $this->Execute(sprintf($this->metaKeySQL,($table))); - // fetch all result in once for performance. - $keys =& $rskey->GetArray(); - if (isset($savem)) $this->SetFetchMode($savem); - $ADODB_FETCH_MODE = $save; - - $rskey->Close(); - unset($rskey); - } - - $rsdefa = array(); - if (!empty($this->metaDefaultsSQL)) { - $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; - $sql = sprintf($this->metaDefaultsSQL, ($table)); - $rsdef = $this->Execute($sql); - if (isset($savem)) $this->SetFetchMode($savem); - $ADODB_FETCH_MODE = $save; - - if ($rsdef) { - while (!$rsdef->EOF) { - $num = $rsdef->fields['num']; - $s = $rsdef->fields['def']; - if (strpos($s,'::')===false && substr($s, 0, 1) == "'") { /* quoted strings hack... for now... fixme */ - $s = substr($s, 1); - $s = substr($s, 0, strlen($s) - 1); - } - - $rsdefa[$num] = $s; - $rsdef->MoveNext(); - } - } else { - ADOConnection::outp( "==> SQL => " . $sql); - } - unset($rsdef); - } - - $retarr = array(); - while (!$rs->EOF) { - $fld = new ADOFieldObject(); - $fld->name = $rs->fields[0]; - $fld->type = $rs->fields[1]; - $fld->max_length = $rs->fields[2]; - if ($fld->max_length <= 0) $fld->max_length = $rs->fields[3]-4; - if ($fld->max_length <= 0) $fld->max_length = -1; - if ($fld->type == 'numeric') { - $fld->scale = $fld->max_length & 0xFFFF; - $fld->max_length >>= 16; - } - // dannym - // 5 hasdefault; 6 num-of-column - $fld->has_default = ($rs->fields[5] == 't'); - if ($fld->has_default) { - $fld->default_value = $rsdefa[$rs->fields[6]]; - } - - //Freek - $fld->not_null = $rs->fields[4] == 't'; - - - // Freek - if (is_array($keys)) { - foreach($keys as $key) { - if ($fld->name == $key['column_name'] AND $key['primary_key'] == 't') - $fld->primary_key = true; - if ($fld->name == $key['column_name'] AND $key['unique_key'] == 't') - $fld->unique = true; // What name is more compatible? - } - } - - if ($ADODB_FETCH_MODE == ADODB_FETCH_NUM) $retarr[] = $fld; - else $retarr[($normalize) ? strtoupper($fld->name) : $fld->name] = $fld; - - $rs->MoveNext(); - } - $rs->Close(); - if (empty($retarr)) - return $false; - else - return $retarr; - - } - - function &MetaIndexes ($table, $primary = FALSE) - { - global $ADODB_FETCH_MODE; - - $schema = false; - $this->_findschema($table,$schema); - - if ($schema) { // requires pgsql 7.3+ - pg_namespace used. - $sql = ' -SELECT c.relname as "Name", i.indisunique as "Unique", i.indkey as "Columns" -FROM pg_catalog.pg_class c -JOIN pg_catalog.pg_index i ON i.indexrelid=c.oid -JOIN pg_catalog.pg_class c2 ON c2.oid=i.indrelid - ,pg_namespace n -WHERE (c2.relname=\'%s\' or c2.relname=lower(\'%s\')) and c.relnamespace=c2.relnamespace and c.relnamespace=n.oid and n.nspname=\'%s\''; - } else { - $sql = ' -SELECT c.relname as "Name", i.indisunique as "Unique", i.indkey as "Columns" -FROM pg_catalog.pg_class c -JOIN pg_catalog.pg_index i ON i.indexrelid=c.oid -JOIN pg_catalog.pg_class c2 ON c2.oid=i.indrelid -WHERE (c2.relname=\'%s\' or c2.relname=lower(\'%s\'))'; - } - - if ($primary == FALSE) { - $sql .= ' AND i.indisprimary=false;'; - } - - $save = $ADODB_FETCH_MODE; - $ADODB_FETCH_MODE = ADODB_FETCH_NUM; - if ($this->fetchMode !== FALSE) { - $savem = $this->SetFetchMode(FALSE); - } - - $rs = $this->Execute(sprintf($sql,$table,$table,$schema)); - if (isset($savem)) { - $this->SetFetchMode($savem); - } - $ADODB_FETCH_MODE = $save; - - if (!is_object($rs)) { - $false = false; - return $false; - } - - $col_names = $this->MetaColumnNames($table,true); - $indexes = array(); - while ($row = $rs->FetchRow()) { - $columns = array(); - foreach (explode(' ', $row[2]) as $col) { - $columns[] = $col_names[$col - 1]; - } - - $indexes[$row[0]] = array( - 'unique' => ($row[1] == 't'), - 'columns' => $columns - ); - } - return $indexes; - } - - // returns true or false - // - // examples: - // $db->Connect("host=host1 user=user1 password=secret port=4341"); - // $db->Connect('host1','user1','secret'); - function _connect($str,$user='',$pwd='',$db='',$ctype=0) - { - - if (!function_exists('pg_connect')) return null; - - $this->_errorMsg = false; - - if ($user || $pwd || $db) { - $user = adodb_addslashes($user); - $pwd = adodb_addslashes($pwd); - if (strlen($db) == 0) $db = 'template1'; - $db = adodb_addslashes($db); - if ($str) { - $host = split(":", $str); - if ($host[0]) $str = "host=".adodb_addslashes($host[0]); - else $str = 'host=localhost'; - if (isset($host[1])) $str .= " port=$host[1]"; - else if (!empty($this->port)) $str .= " port=".$this->port; - } - if ($user) $str .= " user=".$user; - if ($pwd) $str .= " password=".$pwd; - if ($db) $str .= " dbname=".$db; - } - - //if ($user) $linea = "user=$user host=$linea password=$pwd dbname=$db port=5432"; - - if ($ctype === 1) { // persistent - $this->_connectionID = pg_pconnect($str); - } else { - if ($ctype === -1) { // nconnect, we trick pgsql ext by changing the connection str - static $ncnt; - - if (empty($ncnt)) $ncnt = 1; - else $ncnt += 1; - - $str .= str_repeat(' ',$ncnt); - } - $this->_connectionID = pg_connect($str); - } - if ($this->_connectionID === false) return false; - $this->Execute("set datestyle='ISO'"); - return true; - } - - function _nconnect($argHostname, $argUsername, $argPassword, $argDatabaseName) - { - return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabaseName,-1); - } - - // returns true or false - // - // examples: - // $db->PConnect("host=host1 user=user1 password=secret port=4341"); - // $db->PConnect('host1','user1','secret'); - function _pconnect($str,$user='',$pwd='',$db='') - { - return $this->_connect($str,$user,$pwd,$db,1); - } - - - // returns queryID or false - function _query($sql,$inputarr) - { - - if ($inputarr) { - /* - It appears that PREPARE/EXECUTE is slower for many queries. - - For query executed 1000 times: - "select id,firstname,lastname from adoxyz - where firstname not like ? and lastname not like ? and id = ?" - - with plan = 1.51861286163 secs - no plan = 1.26903700829 secs - - - - */ - $plan = 'P'.md5($sql); - - $execp = ''; - foreach($inputarr as $v) { - if ($execp) $execp .= ','; - if (is_string($v)) { - if (strncmp($v,"'",1) !== 0) $execp .= $this->qstr($v); - } else { - $execp .= $v; - } - } - - if ($execp) $exsql = "EXECUTE $plan ($execp)"; - else $exsql = "EXECUTE $plan"; - - $rez = @pg_exec($this->_connectionID,$exsql); - if (!$rez) { - # Perhaps plan does not exist? Prepare/compile plan. - $params = ''; - foreach($inputarr as $v) { - if ($params) $params .= ','; - if (is_string($v)) { - $params .= 'VARCHAR'; - } else if (is_integer($v)) { - $params .= 'INTEGER'; - } else { - $params .= "REAL"; - } - } - $sqlarr = explode('?',$sql); - //print_r($sqlarr); - $sql = ''; - $i = 1; - foreach($sqlarr as $v) { - $sql .= $v.' $'.$i; - $i++; - } - $s = "PREPARE $plan ($params) AS ".substr($sql,0,strlen($sql)-2); - //adodb_pr($s); - pg_exec($this->_connectionID,$s); - echo $this->ErrorMsg(); - } - - $rez = pg_exec($this->_connectionID,$exsql); - } else { - $this->_errorMsg = false; - //adodb_backtrace(); - $rez = pg_exec($this->_connectionID,$sql); - } - // check if no data returned, then no need to create real recordset - if ($rez && pg_numfields($rez) <= 0) { - if (is_resource($this->_resultid) && get_resource_type($this->_resultid) === 'pgsql result') { - pg_freeresult($this->_resultid); - } - $this->_resultid = $rez; - return true; - } - - return $rez; - } - - function _errconnect() - { - if (defined('DB_ERROR_CONNECT_FAILED')) return DB_ERROR_CONNECT_FAILED; - else return 'Database connection failed'; - } - - /* Returns: the last error message from previous database operation */ - function ErrorMsg() - { - if ($this->_errorMsg !== false) return $this->_errorMsg; - if (ADODB_PHPVER >= 0x4300) { - if (!empty($this->_resultid)) { - $this->_errorMsg = @pg_result_error($this->_resultid); - if ($this->_errorMsg) return $this->_errorMsg; - } - - if (!empty($this->_connectionID)) { - $this->_errorMsg = @pg_last_error($this->_connectionID); - } else $this->_errorMsg = $this->_errconnect(); - } else { - if (empty($this->_connectionID)) $this->_errconnect(); - else $this->_errorMsg = @pg_errormessage($this->_connectionID); - } - return $this->_errorMsg; - } - - function ErrorNo() - { - $e = $this->ErrorMsg(); - if (strlen($e)) { - return ADOConnection::MetaError($e); - } - return 0; - } - - // returns true or false - function _close() - { - if ($this->transCnt) $this->RollbackTrans(); - if ($this->_resultid) { - @pg_freeresult($this->_resultid); - $this->_resultid = false; - } - @pg_close($this->_connectionID); - $this->_connectionID = false; - return true; - } - - - /* - * Maximum size of C field - */ - function CharMax() - { - return 1000000000; // should be 1 Gb? - } - - /* - * Maximum size of X field - */ - function TextMax() - { - return 1000000000; // should be 1 Gb? - } - - -} - -/*-------------------------------------------------------------------------------------- - Class Name: Recordset ---------------------------------------------------------------------------------------*/ - -class ADORecordSet_postgres64 extends ADORecordSet{ - var $_blobArr; - var $databaseType = "postgres64"; - var $canSeek = true; - function ADORecordSet_postgres64($queryID,$mode=false) - { - if ($mode === false) { - global $ADODB_FETCH_MODE; - $mode = $ADODB_FETCH_MODE; - } - switch ($mode) - { - case ADODB_FETCH_NUM: $this->fetchMode = PGSQL_NUM; break; - case ADODB_FETCH_ASSOC:$this->fetchMode = PGSQL_ASSOC; break; - - case ADODB_FETCH_DEFAULT: - case ADODB_FETCH_BOTH: - default: $this->fetchMode = PGSQL_BOTH; break; - } - $this->adodbFetchMode = $mode; - $this->ADORecordSet($queryID); - } - - function &GetRowAssoc($upper=true) - { - if ($this->fetchMode == PGSQL_ASSOC && !$upper) return $this->fields; - $row =& ADORecordSet::GetRowAssoc($upper); - return $row; - } - - function _initrs() - { - global $ADODB_COUNTRECS; - $qid = $this->_queryID; - $this->_numOfRows = ($ADODB_COUNTRECS)? @pg_numrows($qid):-1; - $this->_numOfFields = @pg_numfields($qid); - - // cache types for blob decode check - // apparently pg_fieldtype actually performs an sql query on the database to get the type. - if (empty($this->connection->noBlobs)) - for ($i=0, $max = $this->_numOfFields; $i < $max; $i++) { - if (pg_fieldtype($qid,$i) == 'bytea') { - $this->_blobArr[$i] = pg_fieldname($qid,$i); - } - } - } - - /* Use associative array to get fields array */ - function Fields($colname) - { - if ($this->fetchMode != PGSQL_NUM) return @$this->fields[$colname]; - - if (!$this->bind) { - $this->bind = array(); - for ($i=0; $i < $this->_numOfFields; $i++) { - $o = $this->FetchField($i); - $this->bind[strtoupper($o->name)] = $i; - } - } - return $this->fields[$this->bind[strtoupper($colname)]]; - } - - function &FetchField($off = 0) - { - // offsets begin at 0 - - $o= new ADOFieldObject(); - $o->name = @pg_fieldname($this->_queryID,$off); - $o->type = @pg_fieldtype($this->_queryID,$off); - $o->max_length = @pg_fieldsize($this->_queryID,$off); - return $o; - } - - function _seek($row) - { - return @pg_fetch_row($this->_queryID,$row); - } - - function _decode($blob) - { - eval('$realblob="'.adodb_str_replace(array('"','$'),array('\"','\$'),$blob).'";'); - return $realblob; - } - - function _fixblobs() - { - if ($this->fetchMode == PGSQL_NUM || $this->fetchMode == PGSQL_BOTH) { - foreach($this->_blobArr as $k => $v) { - $this->fields[$k] = ADORecordSet_postgres64::_decode($this->fields[$k]); - } - } - if ($this->fetchMode == PGSQL_ASSOC || $this->fetchMode == PGSQL_BOTH) { - foreach($this->_blobArr as $k => $v) { - $this->fields[$v] = ADORecordSet_postgres64::_decode($this->fields[$v]); - } - } - } - - // 10% speedup to move MoveNext to child class - function MoveNext() - { - if (!$this->EOF) { - $this->_currentRow++; - if ($this->_numOfRows < 0 || $this->_numOfRows > $this->_currentRow) { - $this->fields = @pg_fetch_array($this->_queryID,$this->_currentRow,$this->fetchMode); - if (is_array($this->fields) && $this->fields) { - if (isset($this->_blobArr)) $this->_fixblobs(); - return true; - } - } - $this->fields = false; - $this->EOF = true; - } - return false; - } - - function _fetch() - { - - if ($this->_currentRow >= $this->_numOfRows && $this->_numOfRows >= 0) - return false; - - $this->fields = @pg_fetch_array($this->_queryID,$this->_currentRow,$this->fetchMode); - - if ($this->fields && isset($this->_blobArr)) $this->_fixblobs(); - - return (is_array($this->fields)); - } - - function _close() - { - return @pg_freeresult($this->_queryID); - } - - function MetaType($t,$len=-1,$fieldobj=false) - { - if (is_object($t)) { - $fieldobj = $t; - $t = $fieldobj->type; - $len = $fieldobj->max_length; - } - switch (strtoupper($t)) { - case 'MONEY': // stupid, postgres expects money to be a string - case 'INTERVAL': - case 'CHAR': - case 'CHARACTER': - case 'VARCHAR': - case 'NAME': - case 'BPCHAR': - case '_VARCHAR': - case 'INET': - if ($len <= $this->blobSize) return 'C'; - - case 'TEXT': - return 'X'; - - case 'IMAGE': // user defined type - case 'BLOB': // user defined type - case 'BIT': // This is a bit string, not a single bit, so don't return 'L' - case 'VARBIT': - case 'BYTEA': - return 'B'; - - case 'BOOL': - case 'BOOLEAN': - return 'L'; - - case 'DATE': - return 'D'; - - case 'TIME': - case 'DATETIME': - case 'TIMESTAMP': - case 'TIMESTAMPTZ': - return 'T'; - - case 'SMALLINT': - case 'BIGINT': - case 'INTEGER': - case 'INT8': - case 'INT4': - case 'INT2': - if (isset($fieldobj) && - empty($fieldobj->primary_key) && empty($fieldobj->unique)) return 'I'; - - case 'OID': - case 'SERIAL': - return 'R'; - - default: - return 'N'; - } - } - -} -?>
\ No newline at end of file diff --git a/framework/3rdParty/adodb/drivers/adodb-postgres7.inc.php b/framework/3rdParty/adodb/drivers/adodb-postgres7.inc.php deleted file mode 100644 index 7dc22cc5..00000000 --- a/framework/3rdParty/adodb/drivers/adodb-postgres7.inc.php +++ /dev/null @@ -1,262 +0,0 @@ -<?php -/* - V4.81 3 May 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved. - Released under both BSD license and Lesser GPL library license. - Whenever there is any discrepancy between the two licenses, - the BSD license will take precedence. - Set tabs to 4. - - Postgres7 support. - 28 Feb 2001: Currently indicate that we support LIMIT - 01 Dec 2001: dannym added support for default values -*/ - -// security - hide paths -if (!defined('ADODB_DIR')) die(); - -include_once(ADODB_DIR."/drivers/adodb-postgres64.inc.php"); - -class ADODB_postgres7 extends ADODB_postgres64 { - var $databaseType = 'postgres7'; - var $hasLimit = true; // set to true for pgsql 6.5+ only. support pgsql/mysql SELECT * FROM TABLE LIMIT 10 - var $ansiOuter = true; - var $charSet = true; //set to true for Postgres 7 and above - PG client supports encodings - - function ADODB_postgres7() - { - $this->ADODB_postgres64(); - if (ADODB_ASSOC_CASE !== 2) { - $this->rsPrefix .= 'assoc_'; - } - $this->_bindInputArray = PHP_VERSION >= 5.1; - } - - - // the following should be compat with postgresql 7.2, - // which makes obsolete the LIMIT limit,offset syntax - function &SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs2cache=0) - { - $offsetStr = ($offset >= 0) ? " OFFSET ".((integer)$offset) : ''; - $limitStr = ($nrows >= 0) ? " LIMIT ".((integer)$nrows) : ''; - if ($secs2cache) - $rs =& $this->CacheExecute($secs2cache,$sql."$limitStr$offsetStr",$inputarr); - else - $rs =& $this->Execute($sql."$limitStr$offsetStr",$inputarr); - - return $rs; - } - /* - function Prepare($sql) - { - $info = $this->ServerInfo(); - if ($info['version']>=7.3) { - return array($sql,false); - } - return $sql; - } - */ - - // from Edward Jaramilla, improved version - works on pg 7.4 - function MetaForeignKeys($table, $owner=false, $upper=false) - { - $sql = 'SELECT t.tgargs as args - FROM - pg_trigger t,pg_class c,pg_proc p - WHERE - t.tgenabled AND - t.tgrelid = c.oid AND - t.tgfoid = p.oid AND - p.proname = \'RI_FKey_check_ins\' AND - c.relname = \''.strtolower($table).'\' - ORDER BY - t.tgrelid'; - - $rs =& $this->Execute($sql); - - if ($rs && !$rs->EOF) { - $arr =& $rs->GetArray(); - $a = array(); - foreach($arr as $v) - { - $data = explode(chr(0), $v['args']); - if ($upper) { - $a[strtoupper($data[2])][] = strtoupper($data[4].'='.$data[5]); - } else { - $a[$data[2]][] = $data[4].'='.$data[5]; - } - } - return $a; - } - return false; - } - - function _query($sql,$inputarr) - { - if (! $this->_bindInputArray) { - // We don't have native support for parameterized queries, so let's emulate it at the parent - return ADODB_postgres64::_query($sql, $inputarr); - } - // -- added Cristiano da Cunha Duarte - if ($inputarr) { - $sqlarr = explode('?',trim($sql)); - $sql = ''; - $i = 1; - $last = sizeof($sqlarr)-1; - foreach($sqlarr as $v) { - if ($last < $i) $sql .= $v; - else $sql .= $v.' $'.$i; - $i++; - } - - $rez = pg_query_params($this->_connectionID,$sql, $inputarr); - } else { - $rez = pg_query($this->_connectionID,$sql); - } - // check if no data returned, then no need to create real recordset - if ($rez && pg_numfields($rez) <= 0) { - if (is_resource($this->_resultid) && get_resource_type($this->_resultid) === 'pgsql result') { - pg_freeresult($this->_resultid); - } - $this->_resultid = $rez; - return true; - } - return $rez; - } - - // this is a set of functions for managing client encoding - very important if the encodings - // of your database and your output target (i.e. HTML) don't match - //for instance, you may have UNICODE database and server it on-site as WIN1251 etc. - // GetCharSet - get the name of the character set the client is using now - // the functions should work with Postgres 7.0 and above, the set of charsets supported - // depends on compile flags of postgres distribution - if no charsets were compiled into the server - // it will return 'SQL_ANSI' always - function GetCharSet() - { - //we will use ADO's builtin property charSet - $this->charSet = @pg_client_encoding($this->_connectionID); - if (!$this->charSet) { - return false; - } else { - return $this->charSet; - } - } - - // SetCharSet - switch the client encoding - function SetCharSet($charset_name) - { - $this->GetCharSet(); - if ($this->charSet !== $charset_name) { - $if = pg_set_client_encoding($this->_connectionID, $charset_name); - if ($if == "0" & $this->GetCharSet() == $charset_name) { - return true; - } else return false; - } else return true; - } - -} - -/*-------------------------------------------------------------------------------------- - Class Name: Recordset ---------------------------------------------------------------------------------------*/ - -class ADORecordSet_postgres7 extends ADORecordSet_postgres64{ - - var $databaseType = "postgres7"; - - - function ADORecordSet_postgres7($queryID,$mode=false) - { - $this->ADORecordSet_postgres64($queryID,$mode); - } - - // 10% speedup to move MoveNext to child class - function MoveNext() - { - if (!$this->EOF) { - $this->_currentRow++; - if ($this->_numOfRows < 0 || $this->_numOfRows > $this->_currentRow) { - $this->fields = @pg_fetch_array($this->_queryID,$this->_currentRow,$this->fetchMode); - - if (is_array($this->fields)) { - if ($this->fields && isset($this->_blobArr)) $this->_fixblobs(); - return true; - } - } - $this->fields = false; - $this->EOF = true; - } - return false; - } - -} - -class ADORecordSet_assoc_postgres7 extends ADORecordSet_postgres64{ - - var $databaseType = "postgres7"; - - - function ADORecordSet_assoc_postgres7($queryID,$mode=false) - { - $this->ADORecordSet_postgres64($queryID,$mode); - } - - function _fetch() - { - if ($this->_currentRow >= $this->_numOfRows && $this->_numOfRows >= 0) - return false; - - $this->fields = @pg_fetch_array($this->_queryID,$this->_currentRow,$this->fetchMode); - - if ($this->fields) { - if (isset($this->_blobArr)) $this->_fixblobs(); - $this->_updatefields(); - } - - return (is_array($this->fields)); - } - - // Create associative array - function _updatefields() - { - if (ADODB_ASSOC_CASE == 2) return; // native - - $arr = array(); - $lowercase = (ADODB_ASSOC_CASE == 0); - - foreach($this->fields as $k => $v) { - if (is_integer($k)) $arr[$k] = $v; - else { - if ($lowercase) - $arr[strtolower($k)] = $v; - else - $arr[strtoupper($k)] = $v; - } - } - $this->fields = $arr; - } - - function MoveNext() - { - if (!$this->EOF) { - $this->_currentRow++; - if ($this->_numOfRows < 0 || $this->_numOfRows > $this->_currentRow) { - $this->fields = @pg_fetch_array($this->_queryID,$this->_currentRow,$this->fetchMode); - - if (is_array($this->fields)) { - if ($this->fields) { - if (isset($this->_blobArr)) $this->_fixblobs(); - - $this->_updatefields(); - } - return true; - } - } - - - $this->fields = false; - $this->EOF = true; - } - return false; - } -} -?>
\ No newline at end of file diff --git a/framework/3rdParty/adodb/drivers/adodb-sqlite.inc.php b/framework/3rdParty/adodb/drivers/adodb-sqlite.inc.php deleted file mode 100644 index 5c783747..00000000 --- a/framework/3rdParty/adodb/drivers/adodb-sqlite.inc.php +++ /dev/null @@ -1,400 +0,0 @@ -<?php -/* -V4.81 3 May 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved. - Released under both BSD license and Lesser GPL library license. - Whenever there is any discrepancy between the two licenses, - the BSD license will take precedence. - - Latest version is available at http://adodb.sourceforge.net - - SQLite info: http://www.hwaci.com/sw/sqlite/ - - Install Instructions: - ==================== - 1. Place this in adodb/drivers - 2. Rename the file, remove the .txt prefix. -*/ - -// security - hide paths -if (!defined('ADODB_DIR')) die(); - -class ADODB_sqlite extends ADOConnection { - var $databaseType = "sqlite"; - var $replaceQuote = "''"; // string to use to replace quotes - var $concat_operator='||'; - var $_errorNo = 0; - var $hasLimit = true; - var $hasInsertID = true; /// supports autoincrement ID? - var $hasAffectedRows = true; /// supports affected rows for update/delete? - var $metaTablesSQL = "SELECT name FROM sqlite_master WHERE type='table' ORDER BY name"; - var $sysDate = "adodb_date('Y-m-d')"; - var $sysTimeStamp = "adodb_date('Y-m-d H:i:s')"; - var $fmtTimeStamp = "'Y-m-d H:i:s'"; - - function ADODB_sqlite() - { - } - -/* - function __get($name) - { - switch($name) { - case 'sysDate': return "'".date($this->fmtDate)."'"; - case 'sysTimeStamp' : return "'".date($this->sysTimeStamp)."'"; - } - }*/ - - function ServerInfo() - { - $arr['version'] = sqlite_libversion(); - $arr['description'] = 'SQLite '; - $arr['encoding'] = sqlite_libencoding(); - return $arr; - } - - function BeginTrans() - { - if ($this->transOff) return true; - $ret = $this->Execute("BEGIN TRANSACTION"); - $this->transCnt += 1; - return true; - } - - function CommitTrans($ok=true) - { - if ($this->transOff) return true; - if (!$ok) return $this->RollbackTrans(); - $ret = $this->Execute("COMMIT"); - if ($this->transCnt>0)$this->transCnt -= 1; - return !empty($ret); - } - - function RollbackTrans() - { - if ($this->transOff) return true; - $ret = $this->Execute("ROLLBACK"); - if ($this->transCnt>0)$this->transCnt -= 1; - return !empty($ret); - } - - // mark newnham - function &MetaColumns($tab) - { - global $ADODB_FETCH_MODE; - $false = false; - $save = $ADODB_FETCH_MODE; - $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; - if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false); - $rs = $this->Execute("PRAGMA table_info('$tab')"); - if (isset($savem)) $this->SetFetchMode($savem); - if (!$rs) { - $ADODB_FETCH_MODE = $save; - return $false; - } - $arr = array(); - while ($r = $rs->FetchRow()) { - - $type = explode('(',$r['type']); - $size = ''; - if (sizeof($type)==2) - $size = trim($type[1],')'); - $fn = strtoupper($r['name']); - $fld = new ADOFieldObject; - $fld->name = $r['name']; - $fld->type = $type[0]; - $fld->max_length = $size; - $fld->not_null = $r['notnull']; - $fld->default_value = $r['dflt_value']; - $fld->scale = 0; - $fld->primary_key = $r['pk'] == '1' ? true : null; - if ($save == ADODB_FETCH_NUM) $arr[] = $fld; - else $arr[strtoupper($fld->name)] = $fld; - } - $rs->Close(); - $ADODB_FETCH_MODE = $save; - return $arr; - } - - function _init($parentDriver) - { - - $parentDriver->hasTransactions = false; - $parentDriver->hasInsertID = true; - } - - function _insertid() - { - return sqlite_last_insert_rowid($this->_connectionID); - } - - function _affectedrows() - { - return sqlite_changes($this->_connectionID); - } - - function ErrorMsg() - { - if ($this->_logsql) return $this->_errorMsg; - return ($this->_errorNo) ? sqlite_error_string($this->_errorNo) : ''; - } - - function ErrorNo() - { - return $this->_errorNo; - } - - function SQLDate($fmt, $col=false) - { - $fmt = $this->qstr($fmt); - return ($col) ? "adodb_date2($fmt,$col)" : "adodb_date($fmt)"; - } - - - function _createFunctions() - { - @sqlite_create_function($this->_connectionID, 'adodb_date', 'adodb_date', 1); - @sqlite_create_function($this->_connectionID, 'adodb_date2', 'adodb_date2', 2); - } - - - // returns true or false - function _connect($argHostname, $argUsername, $argPassword, $argDatabasename) - { - if (!function_exists('sqlite_open')) return null; - if (empty($argHostname) && $argDatabasename) $argHostname = $argDatabasename; - - $this->_connectionID = sqlite_open($argHostname); - if ($this->_connectionID === false) return false; - $this->_createFunctions(); - return true; - } - - // returns true or false - function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename) - { - if (!function_exists('sqlite_open')) return null; - if (empty($argHostname) && $argDatabasename) $argHostname = $argDatabasename; - - $this->_connectionID = sqlite_popen($argHostname); - if ($this->_connectionID === false) return false; - $this->_createFunctions(); - return true; - } - - // returns query ID if successful, otherwise false - function _query($sql,$inputarr=false) - { - $rez = sqlite_query($sql,$this->_connectionID); - if (!$rez) { - $this->_errorNo = sqlite_last_error($this->_connectionID); - } - - return $rez; - } - - function &SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs2cache=0) - { - $offsetStr = ($offset >= 0) ? " OFFSET $offset" : ''; - $limitStr = ($nrows >= 0) ? " LIMIT $nrows" : ($offset >= 0 ? ' LIMIT 999999999' : ''); - if ($secs2cache) - $rs =& $this->CacheExecute($secs2cache,$sql."$limitStr$offsetStr",$inputarr); - else - $rs =& $this->Execute($sql."$limitStr$offsetStr",$inputarr); - - return $rs; - } - - /* - This algorithm is not very efficient, but works even if table locking - is not available. - - Will return false if unable to generate an ID after $MAXLOOPS attempts. - */ - var $_genSeqSQL = "create table %s (id integer)"; - - function GenID($seq='adodbseq',$start=1) - { - // if you have to modify the parameter below, your database is overloaded, - // or you need to implement generation of id's yourself! - $MAXLOOPS = 100; - //$this->debug=1; - while (--$MAXLOOPS>=0) { - @($num = $this->GetOne("select id from $seq")); - if ($num === false) { - $this->Execute(sprintf($this->_genSeqSQL ,$seq)); - $start -= 1; - $num = '0'; - $ok = $this->Execute("insert into $seq values($start)"); - if (!$ok) return false; - } - $this->Execute("update $seq set id=id+1 where id=$num"); - - if ($this->affected_rows() > 0) { - $num += 1; - $this->genID = $num; - return $num; - } - } - if ($fn = $this->raiseErrorFn) { - $fn($this->databaseType,'GENID',-32000,"Unable to generate unique id after $MAXLOOPS attempts",$seq,$num); - } - return false; - } - - function CreateSequence($seqname='adodbseq',$start=1) - { - if (empty($this->_genSeqSQL)) return false; - $ok = $this->Execute(sprintf($this->_genSeqSQL,$seqname)); - if (!$ok) return false; - $start -= 1; - return $this->Execute("insert into $seqname values($start)"); - } - - var $_dropSeqSQL = 'drop table %s'; - function DropSequence($seqname) - { - if (empty($this->_dropSeqSQL)) return false; - return $this->Execute(sprintf($this->_dropSeqSQL,$seqname)); - } - - // returns true or false - function _close() - { - return @sqlite_close($this->_connectionID); - } - - function &MetaIndexes($table, $primary = FALSE, $owner=false) - { - $false = false; - // save old fetch mode - global $ADODB_FETCH_MODE; - $save = $ADODB_FETCH_MODE; - $ADODB_FETCH_MODE = ADODB_FETCH_NUM; - if ($this->fetchMode !== FALSE) { - $savem = $this->SetFetchMode(FALSE); - } - $SQL=sprintf("SELECT name,sql FROM sqlite_master WHERE type='index' AND tbl_name='%s'", strtolower($table)); - $rs = $this->Execute($SQL); - if (!is_object($rs)) { - if (isset($savem)) - $this->SetFetchMode($savem); - $ADODB_FETCH_MODE = $save; - return $false; - } - - $indexes = array (); - while ($row = $rs->FetchRow()) { - if ($primary && preg_match("/primary/i",$row[1]) == 0) continue; - if (!isset($indexes[$row[0]])) { - - $indexes[$row[0]] = array( - 'unique' => preg_match("/unique/i",$row[1]), - 'columns' => array()); - } - /** - * There must be a more elegant way of doing this, - * the index elements appear in the SQL statement - * in cols[1] between parentheses - * e.g CREATE UNIQUE INDEX ware_0 ON warehouse (org,warehouse) - */ - $cols = explode("(",$row[1]); - $cols = explode(")",$cols[1]); - array_pop($cols); - $indexes[$row[0]]['columns'] = $cols; - } - if (isset($savem)) { - $this->SetFetchMode($savem); - $ADODB_FETCH_MODE = $save; - } - return $indexes; - } - -} - -/*-------------------------------------------------------------------------------------- - Class Name: Recordset ---------------------------------------------------------------------------------------*/ - -class ADORecordset_sqlite extends ADORecordSet { - - var $databaseType = "sqlite"; - var $bind = false; - - function ADORecordset_sqlite($queryID,$mode=false) - { - - if ($mode === false) { - global $ADODB_FETCH_MODE; - $mode = $ADODB_FETCH_MODE; - } - switch($mode) { - case ADODB_FETCH_NUM: $this->fetchMode = SQLITE_NUM; break; - case ADODB_FETCH_ASSOC: $this->fetchMode = SQLITE_ASSOC; break; - default: $this->fetchMode = SQLITE_BOTH; break; - } - $this->adodbFetchMode = $mode; - - $this->_queryID = $queryID; - - $this->_inited = true; - $this->fields = array(); - if ($queryID) { - $this->_currentRow = 0; - $this->EOF = !$this->_fetch(); - @$this->_initrs(); - } else { - $this->_numOfRows = 0; - $this->_numOfFields = 0; - $this->EOF = true; - } - - return $this->_queryID; - } - - - function &FetchField($fieldOffset = -1) - { - $fld = new ADOFieldObject; - $fld->name = sqlite_field_name($this->_queryID, $fieldOffset); - $fld->type = 'VARCHAR'; - $fld->max_length = -1; - return $fld; - } - - function _initrs() - { - $this->_numOfRows = @sqlite_num_rows($this->_queryID); - $this->_numOfFields = @sqlite_num_fields($this->_queryID); - } - - function Fields($colname) - { - if ($this->fetchMode != SQLITE_NUM) return $this->fields[$colname]; - if (!$this->bind) { - $this->bind = array(); - for ($i=0; $i < $this->_numOfFields; $i++) { - $o = $this->FetchField($i); - $this->bind[strtoupper($o->name)] = $i; - } - } - - return $this->fields[$this->bind[strtoupper($colname)]]; - } - - function _seek($row) - { - return sqlite_seek($this->_queryID, $row); - } - - function _fetch($ignore_fields=false) - { - $this->fields = @sqlite_fetch_array($this->_queryID,$this->fetchMode); - return !empty($this->fields); - } - - function _close() - { - } - -} -?>
\ No newline at end of file |