From ec9ef473ce957d88f493d3941009b02dbee6c87d Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Sat, 10 Jul 2004 07:19:40 +0000 Subject: [PATCH] imported ADOdb ver. 4.50 which should solve many php5 probs --- phpgwapi/inc/adodb/adodb-csvlib.inc.php | 18 +- phpgwapi/inc/adodb/adodb-datadict.inc.php | 8 +- phpgwapi/inc/adodb/adodb-error.inc.php | 8 +- phpgwapi/inc/adodb/adodb-errorhandler.inc.php | 3 +- phpgwapi/inc/adodb/adodb-errorpear.inc.php | 2 +- phpgwapi/inc/adodb/adodb-exceptions.inc.php | 5 +- phpgwapi/inc/adodb/adodb-iterator.inc.php | 17 +- phpgwapi/inc/adodb/adodb-lib.inc.php | 79 ++-- phpgwapi/inc/adodb/adodb-pager.inc.php | 3 +- phpgwapi/inc/adodb/adodb-pear.inc.php | 8 +- phpgwapi/inc/adodb/adodb-perf.inc.php | 18 +- phpgwapi/inc/adodb/adodb-php4.inc.php | 2 +- phpgwapi/inc/adodb/adodb-time.inc.php | 70 ++- phpgwapi/inc/adodb/adodb.inc.php | 214 ++++----- .../adodb/datadict/datadict-access.inc.php | 5 +- .../inc/adodb/datadict/datadict-db2.inc.php | 4 +- .../adodb/datadict/datadict-firebird.inc.php | 151 ++++++ .../adodb/datadict/datadict-generic.inc.php | 5 +- .../inc/adodb/datadict/datadict-ibase.inc.php | 5 +- .../adodb/datadict/datadict-informix.inc.php | 5 +- .../inc/adodb/datadict/datadict-mssql.inc.php | 23 +- .../inc/adodb/datadict/datadict-mysql.inc.php | 5 +- .../inc/adodb/datadict/datadict-oci8.inc.php | 28 +- .../adodb/datadict/datadict-postgres.inc.php | 5 +- .../adodb/datadict/datadict-sybase.inc.php | 5 +- phpgwapi/inc/adodb/docs/docs-adodb.htm | 232 ++++++++-- phpgwapi/inc/adodb/docs/docs-datadict.htm | 8 +- phpgwapi/inc/adodb/docs/docs-perf.htm | 6 +- phpgwapi/inc/adodb/docs/docs-session.htm | 6 +- phpgwapi/inc/adodb/docs/tips_portable_sql.htm | 2 +- .../inc/adodb/drivers/adodb-access.inc.php | 6 +- phpgwapi/inc/adodb/drivers/adodb-ado.inc.php | 13 +- .../adodb/drivers/adodb-ado_access.inc.php | 7 +- .../inc/adodb/drivers/adodb-ado_mssql.inc.php | 57 ++- .../adodb/drivers/adodb-borland_ibase.inc.php | 16 +- phpgwapi/inc/adodb/drivers/adodb-csv.inc.php | 5 +- phpgwapi/inc/adodb/drivers/adodb-db2.inc.php | 7 +- .../inc/adodb/drivers/adodb-fbsql.inc.php | 5 +- .../inc/adodb/drivers/adodb-firebird.inc.php | 10 +- .../inc/adodb/drivers/adodb-ibase.inc.php | 143 ++++-- .../inc/adodb/drivers/adodb-informix.inc.php | 6 +- .../adodb/drivers/adodb-informix72.inc.php | 33 +- phpgwapi/inc/adodb/drivers/adodb-ldap.inc.php | 6 +- .../inc/adodb/drivers/adodb-mssql.inc.php | 13 +- .../inc/adodb/drivers/adodb-mssqlpo.inc.php | 5 +- .../inc/adodb/drivers/adodb-mysql.inc.php | 33 +- .../inc/adodb/drivers/adodb-mysqli.inc.php | 94 ++-- .../inc/adodb/drivers/adodb-mysqlt.inc.php | 5 +- .../inc/adodb/drivers/adodb-netezza.inc.php | 5 +- phpgwapi/inc/adodb/drivers/adodb-oci8.inc.php | 95 +++- .../inc/adodb/drivers/adodb-oci805.inc.php | 5 +- .../inc/adodb/drivers/adodb-oci8po.inc.php | 7 +- phpgwapi/inc/adodb/drivers/adodb-odbc.inc.php | 30 +- .../adodb/drivers/adodb-odbc_mssql.inc.php | 7 +- .../adodb/drivers/adodb-odbc_oracle.inc.php | 6 +- .../inc/adodb/drivers/adodb-odbtp.inc.php | 7 +- .../adodb/drivers/adodb-odbtp_unicode.inc.php | 7 +- .../inc/adodb/drivers/adodb-oracle.inc.php | 40 +- phpgwapi/inc/adodb/drivers/adodb-pdo.inc.php | 319 +++++++++++++ .../inc/adodb/drivers/adodb-postgres.inc.php | 2 +- .../adodb/drivers/adodb-postgres64.inc.php | 58 +-- .../inc/adodb/drivers/adodb-postgres7.inc.php | 5 +- .../inc/adodb/drivers/adodb-proxy.inc.php | 5 +- .../inc/adodb/drivers/adodb-sapdb.inc.php | 7 +- .../adodb/drivers/adodb-sqlanywhere.inc.php | 7 +- .../inc/adodb/drivers/adodb-sqlite.inc.php | 11 +- .../inc/adodb/drivers/adodb-sqlitepo.inc.php | 62 +++ .../inc/adodb/drivers/adodb-sybase.inc.php | 11 +- phpgwapi/inc/adodb/drivers/adodb-vfp.inc.php | 7 +- phpgwapi/inc/adodb/lang/adodb-pl.inc.php | 36 ++ phpgwapi/inc/adodb/license.txt | 4 +- .../inc/adodb/pear/Auth/Container/ADOdb.php | 436 ++++++++++++++++++ phpgwapi/inc/adodb/pear/readme.Auth.txt | 20 + phpgwapi/inc/adodb/perf/perf-db2.inc.php | 6 +- phpgwapi/inc/adodb/perf/perf-informix.inc.php | 7 +- phpgwapi/inc/adodb/perf/perf-mssql.inc.php | 7 +- phpgwapi/inc/adodb/perf/perf-mysql.inc.php | 7 +- phpgwapi/inc/adodb/perf/perf-oci8.inc.php | 20 +- phpgwapi/inc/adodb/perf/perf-postgres.inc.php | 7 +- phpgwapi/inc/adodb/pivottable.inc.php | 2 +- phpgwapi/inc/adodb/rsfilter.inc.php | 2 +- phpgwapi/inc/adodb/server.php | 2 +- .../inc/adodb/session/adodb-encrypt-md5.php | 3 + phpgwapi/inc/adodb/session/adodb-session.php | 4 +- .../adodb/session/old/adodb-cryptsession.php | 2 +- .../adodb/session/old/adodb-session-clob.php | 2 +- .../inc/adodb/session/old/adodb-session.php | 2 +- phpgwapi/inc/adodb/tests/benchmark.php | 2 +- phpgwapi/inc/adodb/tests/client.php | 2 +- phpgwapi/inc/adodb/tests/pdo.php | 42 ++ phpgwapi/inc/adodb/tests/test-datadict.php | 6 +- phpgwapi/inc/adodb/tests/test-php5.php | 9 +- phpgwapi/inc/adodb/tests/test-xmlschema.php | 19 +- phpgwapi/inc/adodb/tests/test.php | 82 ++-- phpgwapi/inc/adodb/tests/test2.php | 2 +- phpgwapi/inc/adodb/tests/test3.php | 2 +- phpgwapi/inc/adodb/tests/test4.php | 2 +- phpgwapi/inc/adodb/tests/test5.php | 4 +- phpgwapi/inc/adodb/tests/testcache.php | 4 +- .../inc/adodb/tests/testdatabases.inc.php | 20 +- phpgwapi/inc/adodb/tests/testgenid.php | 2 +- phpgwapi/inc/adodb/tests/testmssql.php | 2 +- phpgwapi/inc/adodb/tests/testoci8.php | 4 +- phpgwapi/inc/adodb/tests/testoci8cursor.php | 10 +- phpgwapi/inc/adodb/tests/testpaging.php | 4 +- phpgwapi/inc/adodb/tests/testpear.php | 4 +- phpgwapi/inc/adodb/tests/testsessions.php | 4 +- phpgwapi/inc/adodb/toexport.inc.php | 4 +- phpgwapi/inc/adodb/tohtml.inc.php | 4 +- 109 files changed, 2323 insertions(+), 597 deletions(-) create mode 100644 phpgwapi/inc/adodb/datadict/datadict-firebird.inc.php create mode 100644 phpgwapi/inc/adodb/drivers/adodb-pdo.inc.php create mode 100644 phpgwapi/inc/adodb/drivers/adodb-sqlitepo.inc.php create mode 100644 phpgwapi/inc/adodb/lang/adodb-pl.inc.php create mode 100644 phpgwapi/inc/adodb/pear/Auth/Container/ADOdb.php create mode 100644 phpgwapi/inc/adodb/pear/readme.Auth.txt create mode 100644 phpgwapi/inc/adodb/tests/pdo.php diff --git a/phpgwapi/inc/adodb/adodb-csvlib.inc.php b/phpgwapi/inc/adodb/adodb-csvlib.inc.php index 17a606a3f9..80d0d8cb62 100644 --- a/phpgwapi/inc/adodb/adodb-csvlib.inc.php +++ b/phpgwapi/inc/adodb/adodb-csvlib.inc.php @@ -1,15 +1,19 @@ timeCreated = $ttl; + else { + $err = "Unable to unserialize recordset"; + //echo htmlspecialchars($text),' !--END--!

'; + } return $rs; } diff --git a/phpgwapi/inc/adodb/adodb-datadict.inc.php b/phpgwapi/inc/adodb/adodb-datadict.inc.php index ea68b3fe6e..80e77767a3 100644 --- a/phpgwapi/inc/adodb/adodb-datadict.inc.php +++ b/phpgwapi/inc/adodb/adodb-datadict.inc.php @@ -1,7 +1,7 @@ DB_ERROR_NOSUCHTABLE, '/Relation [\"\'].*[\"\'] already exists|Cannot insert a duplicate key into (a )?unique index.*/' => DB_ERROR_ALREADY_EXISTS, @@ -96,7 +98,9 @@ function adodb_error_pg($errormsg) '/pg_atoi: error in .*: can\'t parse /' => DB_ERROR_INVALID_NUMBER, '/ttribute [\"\'].*[\"\'] not found|Relation [\"\'].*[\"\'] does not have attribute [\"\'].*[\"\']/' => DB_ERROR_NOSUCHFIELD, '/parser: parse error at or near \"/' => DB_ERROR_SYNTAX, - '/referential integrity violation/' => DB_ERROR_CONSTRAINT + '/referential integrity violation/' => DB_ERROR_CONSTRAINT, + '/Relation [\"\'].*[\"\'] already exists|Cannot insert a duplicate key into (a )?unique index.*|duplicate key violates unique constraint/' + => DB_ERROR_ALREADY_EXISTS ); reset($error_regexps); while (list($regexp,$code) = each($error_regexps)) { diff --git a/phpgwapi/inc/adodb/adodb-errorhandler.inc.php b/phpgwapi/inc/adodb/adodb-errorhandler.inc.php index c5ed4cc307..ff8c35059a 100644 --- a/phpgwapi/inc/adodb/adodb-errorhandler.inc.php +++ b/phpgwapi/inc/adodb/adodb-errorhandler.inc.php @@ -1,6 +1,6 @@ Execute("select * from adoxyz"); foreach($rs as $k => $v) { @@ -19,6 +20,7 @@ Iterator code based on http://cvs.php.net/cvs.php/php-src/ext/spl/examples/cachingiterator.inc?login=2 */ + class ADODB_Iterator implements Iterator { private $rs; @@ -59,9 +61,16 @@ function __toString() { - return 'ADODB Iterator'; + if (isset($rs->databaseType)) $s = ' for '.$rs->databaseType; + else $s = ''; + + return 'ADODB Iterator'.$s; + } + + function hasMore() + { + return !$this->rs->EOF; } - } diff --git a/phpgwapi/inc/adodb/adodb-lib.inc.php b/phpgwapi/inc/adodb/adodb-lib.inc.php index ede10e3917..f6046b5ca3 100644 --- a/phpgwapi/inc/adodb/adodb-lib.inc.php +++ b/phpgwapi/inc/adodb/adodb-lib.inc.php @@ -1,10 +1,13 @@ ".htmlspecialchars($zval).''; + $s .= "'; else $s .= "\n'.htmlspecialchars($zval).''; } else { if (strcasecmp($selected,$defstr)==0) - $s .= "'; + $s .= "'; else $s .= "\n'.htmlspecialchars($zval).''; } @@ -206,12 +209,13 @@ function _adodb_getcount(&$zthis, $sql,$inputarr=false,$secs2cache=0) } if ($qryRecs !== false) return $qryRecs; } - //-------------------------------------------- // query rewrite failed - so try slower way... - // strip off unneeded ORDER BY - $rewritesql = preg_replace('/(\sORDER\s+BY\s.*)/is','',$sql); + // strip off unneeded ORDER BY if no UNION + if (preg_match('/\s*UNION\s*/is', $sql)) $rewritesql = $sql; + else $rewritesql = preg_replace('/(\sORDER\s+BY\s.*)/is','',$sql); + $rstest = &$zthis->Execute($rewritesql,$inputarr); if ($rstest) { $qryRecs = $rstest->RecordCount(); @@ -347,7 +351,7 @@ function &_adodb_pageexecute_no_last_page(&$zthis, $sql, $nrows, $page, $inputar return $rsreturn; } -function _adodb_getupdatesql(&$zthis,&$rs, $arrFields,$forceUpdate=false,$magicq=false) +function _adodb_getupdatesql(&$zthis,&$rs, $arrFields,$forceUpdate=false,$magicq=false,$forcenulls=false) { if (!$rs) { printf(ADODB_BAD_RS,'GetUpdateSQL'); @@ -391,18 +395,23 @@ function _adodb_getupdatesql(&$zthis,&$rs, $arrFields,$forceUpdate=false,$magicq $type = $rs->MetaType($field->type); // is_null requires php 4.0.4 - if ((defined('ADODB_FORCE_NULLS') && is_null($arrFields[$upperfname])) || + if (($forcenulls && is_null($arrFields[$upperfname])) || $arrFields[$upperfname] === 'null') { $setFields .= $field->name . " = null, "; } else { if ($type == 'null') { $type = 'C'; } + + if (strpos($upperfname,' ') !== false) + $fnameq = $zthis->nameQuote.$upperfname.$zthis->nameQuote; + else + $fnameq = $upperfname; //we do this so each driver can customize the sql for //DB specific column types. //Oracle needs BLOB types to be handled with a returning clause //postgres has special needs as well - $setFields .= _adodb_column_sql($zthis, 'U', $type, $upperfname, + $setFields .= _adodb_column_sql($zthis, 'U', $type, $upperfname, $fnameq, $arrFields, $magicq); } } @@ -439,9 +448,9 @@ function _adodb_getupdatesql(&$zthis,&$rs, $arrFields,$forceUpdate=false,$magicq } } -function adodb_key_exists($key, &$arr) +function adodb_key_exists($key, &$arr,$forcenulls=false) { - if (!defined('ADODB_FORCE_NULLS')) { + if (!$forcenulls) { // the following is the old behaviour where null or empty fields are ignored return (!empty($arr[$key])) || (isset($arr[$key]) && strlen($arr[$key])>0); } @@ -459,7 +468,7 @@ function adodb_key_exists($key, &$arr) * * */ -function _adodb_getinsertsql(&$zthis,&$rs,$arrFields,$magicq=false) +function _adodb_getinsertsql(&$zthis,&$rs,$arrFields,$magicq=false,$forcenulls=false) { $tableName = ''; $values = ''; @@ -498,13 +507,19 @@ function _adodb_getinsertsql(&$zthis,&$rs,$arrFields,$magicq=false) // Set the counter for the number of fields that will be inserted. $fieldInsertedCount++; + + if (strpos($upperfname,' ') !== false) + $fnameq = $zthis->nameQuote.$upperfname.$zthis->nameQuote; + else + $fnameq = $upperfname; + // Get the name of the fields to insert - $fields .= $field->name . ", "; + $fields .= $fnameq . ", "; $type = $recordSet->MetaType($field->type); - if ((defined('ADODB_FORCE_NULLS') && is_null($arrFields[$upperfname])) || + if (($forcenulls && is_null($arrFields[$upperfname])) || $arrFields[$upperfname] === 'null') { $values .= "null, "; } else { @@ -512,7 +527,7 @@ function _adodb_getinsertsql(&$zthis,&$rs,$arrFields,$magicq=false) //DB specific column types. //Oracle needs BLOB types to be handled with a returning clause //postgres has special needs as well - $values .= _adodb_column_sql($zthis, 'I', $type, $upperfname, + $values .= _adodb_column_sql($zthis, 'I', $type, $upperfname, $fnameq, $arrFields, $magicq); } } @@ -553,7 +568,7 @@ function _adodb_getinsertsql(&$zthis,&$rs,$arrFields,$magicq=false) * @return string * */ -function _adodb_column_sql_oci8(&$zthis,$action, $type, $fname, $arrFields, $magicq) +function _adodb_column_sql_oci8(&$zthis,$action, $type, $fname, $fnameq, $arrFields, $magicq) { $sql = ''; @@ -570,16 +585,22 @@ function _adodb_column_sql_oci8(&$zthis,$action, $type, $fname, $arrFields, $mag if ($action == 'I') { $sql = 'empty_blob(), '; } else { - $sql = $fname. '=empty_blob(), '; + $sql = $fnameq. '=empty_blob(), '; } //add the variable to the returning clause array //so the user can build this later in //case they want to add more to it $zthis->_returningArray[$fname] = ':xx'.$fname.'xx'; + } else if (empty($arrFields[$fname])){ + if ($action == 'I') { + $sql = 'empty_blob(), '; + } else { + $sql = $fnameq. '=empty_blob(), '; + } } else { //this is to maintain compatibility //with older adodb versions. - $sql = _adodb_column_sql($zthis, $action, $type, $fname, $arrFields, $magicq,false); + $sql = _adodb_column_sql($zthis, $action, $type, $fname, $fnameq, $arrFields, $magicq,false); } break; @@ -593,7 +614,7 @@ function _adodb_column_sql_oci8(&$zthis,$action, $type, $fname, $arrFields, $mag if ($action == 'I') { $sql = ':xx'.$fname.'xx, '; } else { - $sql = $fname.'=:xx'.$fname.'xx, '; + $sql = $fnameq.'=:xx'.$fname.'xx, '; } //add the variable to the returning clause array //so the user can build this later in @@ -602,19 +623,19 @@ function _adodb_column_sql_oci8(&$zthis,$action, $type, $fname, $arrFields, $mag } else { //this is to maintain compatibility //with older adodb versions. - $sql = _adodb_column_sql($zthis, $action, $type, $fname, $arrFields, $magicq,false); + $sql = _adodb_column_sql($zthis, $action, $type, $fname, $fnameq, $arrFields, $magicq,false); } break; default: - $sql = _adodb_column_sql($zthis, $action, $type, $fname, $arrFields, $magicq,false); + $sql = _adodb_column_sql($zthis, $action, $type, $fname, $fnameq, $arrFields, $magicq,false); break; } return $sql; } -function _adodb_column_sql(&$zthis, $action, $type, $fname, $arrFields, $magicq, $recurse=true) +function _adodb_column_sql(&$zthis, $action, $type, $fname, $fnameq, $arrFields, $magicq, $recurse=true) { if ($recurse) { @@ -623,13 +644,13 @@ function _adodb_column_sql(&$zthis, $action, $type, $fname, $arrFields, $magicq, if ($type == 'L') $type = 'C'; break; case 'oci8': - return _adodb_column_sql_oci8($zthis, $action, $type, $fname, $arrFields, $magicq); + return _adodb_column_sql_oci8($zthis, $action, $type, $fname, $fnameq, $arrFields, $magicq); } } $sql = ''; - + switch($type) { case "C": case "X": @@ -637,7 +658,7 @@ function _adodb_column_sql(&$zthis, $action, $type, $fname, $arrFields, $magicq, if ($action == 'I') { $sql = $zthis->qstr($arrFields[$fname],$magicq) . ", "; } else { - $sql .= $fname . "=" . $zthis->qstr($arrFields[$fname],$magicq) . ", "; + $sql .= $fnameq . "=" . $zthis->qstr($arrFields[$fname],$magicq) . ", "; } break; @@ -645,7 +666,7 @@ function _adodb_column_sql(&$zthis, $action, $type, $fname, $arrFields, $magicq, if ($action == 'I') { $sql = $zthis->DBDate($arrFields[$fname]) . ", "; } else { - $sql .= $fname . "=" . $zthis->DBDate($arrFields[$fname]) . ", "; + $sql .= $fnameq . "=" . $zthis->DBDate($arrFields[$fname]) . ", "; } break; @@ -653,7 +674,7 @@ function _adodb_column_sql(&$zthis, $action, $type, $fname, $arrFields, $magicq, if ($action == 'I') { $sql = $zthis->DBTimeStamp($arrFields[$fname]) . ", "; } else { - $sql .= $fname . "=" . $zthis->DBTimeStamp($arrFields[$fname]) . ", "; + $sql .= $fnameq . "=" . $zthis->DBTimeStamp($arrFields[$fname]) . ", "; } break; @@ -665,7 +686,7 @@ function _adodb_column_sql(&$zthis, $action, $type, $fname, $arrFields, $magicq, if ($action == 'I') { $sql .= $val . ", "; } else { - $sql .= $fname . "=" . $val . ", "; + $sql .= $fnameq . "=" . $val . ", "; } break; } diff --git a/phpgwapi/inc/adodb/adodb-pager.inc.php b/phpgwapi/inc/adodb/adodb-pager.inc.php index 355806dac8..f4d2525eb4 100644 --- a/phpgwapi/inc/adodb/adodb-pager.inc.php +++ b/phpgwapi/inc/adodb/adodb-pager.inc.php @@ -1,6 +1,7 @@ trim(substr($sql,0,230)), - 'c'=>substr($sql,0,3900), 'd'=>$params,'e'=>$tracer,'f'=>round($time,6)); + 'c'=>substr($sql,0,3900), 'd'=>$params,'e'=>$tracer,'f'=>adodb_round($time,6)); //var_dump($arr); $saved = $conn->debug; $conn->debug = 0; @@ -402,7 +408,7 @@ Committed_AS: 348732 kB $suffix = ' ... String too long for GET parameter: '.strlen($prefix).''; $prefix = ''; } - $s .= "".round($rs->fields[0],6)."".$rs->fields[2]."".$prefix.htmlspecialchars($sql).$suffix."". + $s .= "".adodb_round($rs->fields[0],6)."".$rs->fields[2]."".$prefix.htmlspecialchars($sql).$suffix."". "".$rs->fields[3]."".$rs->fields[4].""; $rs->MoveNext(); } @@ -478,7 +484,7 @@ Committed_AS: 348732 kB $prefix = ''; $suffix = ''; } - $s .= "".round($rs->fields[0],6)."".$rs->fields[2]."".$prefix.htmlspecialchars($sql).$suffix."". + $s .= "".adodb_round($rs->fields[0],6)."".$rs->fields[2]."".$prefix.htmlspecialchars($sql).$suffix."". "".$rs->fields[3]."".$rs->fields[4].""; $rs->MoveNext(); } @@ -628,7 +634,7 @@ Committed_AS: 348732 kB default: case 'stats': echo $this->HealthCheck(); - $this->conn->debug=1; + //$this->conn->debug=1; echo $this->CheckMemory(); break; case 'poll': diff --git a/phpgwapi/inc/adodb/adodb-php4.inc.php b/phpgwapi/inc/adodb/adodb-php4.inc.php index 90ac18b977..efc8f85e58 100644 --- a/phpgwapi/inc/adodb/adodb-php4.inc.php +++ b/phpgwapi/inc/adodb/adodb-php4.inc.php @@ -1,7 +1,7 @@ 0 + [minutes] => 0 + [hours] => 0 + [mday] => 1 # day of month, eg 1st day of the month + [mon] => 2 # month (eg. Feb) + [year] => 2102 + [yday] => 31 # days in current year + [leap] => # true if leap year + [ndays] => 28 # no of days in current month + ) + + +- 28 Apr 2004 0.13 +Fixed adodb_date to properly support $is_gmt. Thx to Dimitar Angelov. + - 20 Mar 2004 0.12 Fixed month calculation error in adodb_date. 2102-June-01 appeared as 2102-May-32. @@ -237,7 +271,7 @@ First implementation. /* Version Number */ -define('ADODB_DATE_VERSION',0.12); +define('ADODB_DATE_VERSION',0.14); /* We check for Windows as only +ve ints are accepted as dates on Windows. @@ -273,7 +307,7 @@ function adodb_date_test() error_reporting(E_ALL); print "

Testing adodb_date and adodb_mktime. version=".ADODB_DATE_VERSION. "

"; - set_time_limit(0); + @set_time_limit(0); $fail = false; // This flag disables calling of PHP native functions, so we can properly test the code @@ -551,6 +585,9 @@ function _adodb_getdate($origd=false,$fast=false,$is_gmt=false) $_month_table_normal = array("",31,28,31,30,31,30,31,31,30,31,30,31); $_month_table_leaf = array("",31,29,31,30,31,30,31,31,30,31,30,31); + $d366 = $_day_power * 366; + $d365 = $_day_power * 365; + if ($d < 0) { $origd = $d; // The valid range of a 32bit signed timestamp is typically from @@ -558,10 +595,9 @@ function _adodb_getdate($origd=false,$fast=false,$is_gmt=false) for ($a = 1970 ; --$a >= 0;) { $lastd = $d; - if ($leaf = _adodb_is_leap_year($a)) { - $d += $_day_power * 366; - } else - $d += $_day_power * 365; + if ($leaf = _adodb_is_leap_year($a)) $d += $d366; + else $d += $d365; + if ($d >= 0) { $year = $a; break; @@ -589,14 +625,11 @@ function _adodb_getdate($origd=false,$fast=false,$is_gmt=false) $hour = floor($d/$_hour_power); } else { - for ($a = 1970 ;; $a++) { $lastd = $d; - if ($leaf = _adodb_is_leap_year($a)) { - $d -= $_day_power * 366; - } else - $d -= $_day_power * 365; + if ($leaf = _adodb_is_leap_year($a)) $d -= $d366; + else $d -= $d365; if ($d < 0) { $year = $a; break; @@ -660,6 +693,7 @@ function adodb_gmdate($fmt,$d=false) return adodb_date($fmt,$d,true); } +// accepts unix timestamp and iso date format in $d function adodb_date2($fmt, $d=false, $is_gmt=false) { if ($d !== false) { @@ -677,21 +711,25 @@ function adodb_date2($fmt, $d=false, $is_gmt=false) return adodb_date($fmt,$d,$is_gmt); } + /** Return formatted date based on timestamp $d */ function adodb_date($fmt,$d=false,$is_gmt=false) { - if ($d === false) return date($fmt); + if ($d === false) return ($is_gmt)? @gmdate($fmt): @date($fmt); if (!defined('ADODB_TEST_DATES')) { if ((abs($d) <= 0x7FFFFFFF)) { // check if number in 32-bit signed range if (!defined('ADODB_NO_NEGATIVE_TS') || $d >= 0) // if windows, must be +ve integer - return @date($fmt,$d); + return ($is_gmt)? @gmdate($fmt,$d): @date($fmt,$d); + } } $_day_power = 86400; $arr = _adodb_getdate($d,true,$is_gmt); + if (function_exists('adodb_daylight_sv')) adodb_daylight_sv($arr, $is_gmt); + $year = $arr['year']; $month = $arr['mon']; $day = $arr['mday']; @@ -822,6 +860,8 @@ function adodb_gmmktime($hr,$min,$sec,$mon,$day,$year,$is_dst=false) /** Return a timestamp given a local time. Originally by jackbbs. Note that $is_dst is not implemented and is ignored. + + Not a very fast algorithm - O(n) operation. Could be optimized to O(1). */ function adodb_mktime($hr,$min,$sec,$mon,$day,$year,$is_dst=false,$is_gmt=false) { @@ -830,7 +870,9 @@ function adodb_mktime($hr,$min,$sec,$mon,$day,$year,$is_dst=false,$is_gmt=false) // 1 Jan 1970 could generate negative timestamp, which is illegal if (!defined('ADODB_NO_NEGATIVE_TS') || ($year >= 1971)) if (1901 < $year && $year < 2038) - return @mktime($hr,$min,$sec,$mon,$day,$year); + return $is_gmt? + @gmmktime($hr,$min,$sec,$mon,$day,$year): + @mktime($hr,$min,$sec,$mon,$day,$year); } $gmt_different = ($is_gmt) ? 0 : adodb_get_gmt_diff(); diff --git a/phpgwapi/inc/adodb/adodb.inc.php b/phpgwapi/inc/adodb/adodb.inc.php index b9aa9a53af..8f76063074 100644 --- a/phpgwapi/inc/adodb/adodb.inc.php +++ b/phpgwapi/inc/adodb/adodb.inc.php @@ -2,7 +2,7 @@ /* * Set tabs to 4 for best viewing. * - * Latest version is available at http://php.weblogs.com/adodb + * Latest version is available at http://adodb.sourceforge.net * * This is the main include file for ADOdb. * Database specific drivers are stored in the adodb/drivers/adodb-*.inc.php @@ -14,7 +14,7 @@ /** \mainpage - @version V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim\@natsoft.com.my). All rights reserved. + @version V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim\@natsoft.com.my). All rights reserved. Released under both BSD license and Lesser GPL library license. You can choose which license you prefer. @@ -56,7 +56,7 @@ $ADODB_COUNTRECS, // count number of records returned - slows down query $ADODB_CACHE_DIR, // directory to cache recordsets $ADODB_EXTENSION, // ADODB extension installed - $ADODB_COMPAT_PATCH, // If $ADODB_COUNTRECS and this is true, $rs->fields is available on EOF + $ADODB_COMPAT_FETCH, // If $ADODB_COUNTRECS and this is true, $rs->fields is available on EOF $ADODB_FETCH_MODE; // DEFAULT, NUM, ASSOC or BOTH. Default follows native driver default... //============================================================================================== @@ -91,9 +91,13 @@ if (!defined('TIMESTAMP_FIRST_YEAR')) define('TIMESTAMP_FIRST_YEAR',100); - if (strnatcmp(PHP_VERSION,'4.3.0')>=0) { + // PHP's version scheme makes converting to numbers difficult - workaround + $_adodb_ver = (float) PHP_VERSION; + if ($_adodb_ver >= 5.0) { + define('ADODB_PHPVER',0x5000); + } else if ($_adodb_ver > 4.299999) { # 4.3 define('ADODB_PHPVER',0x4300); - } else if (strnatcmp(PHP_VERSION,'4.2.0')>=0) { + } else if ($_adodb_ver > 4.199999) { # 4.2 define('ADODB_PHPVER',0x4200); } else if (strnatcmp(PHP_VERSION,'4.0.5')>=0) { define('ADODB_PHPVER',0x4050); @@ -103,7 +107,7 @@ } //if (!defined('ADODB_ASSOC_CASE')) define('ADODB_ASSOC_CASE',2); - + /** Accepts $src and $dest arrays, replacing string $data @@ -147,7 +151,7 @@ /** * ADODB version as a string. */ - $ADODB_vers = 'V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim#natsoft.com.my). All rights reserved. Released BSD & LGPL.'; + $ADODB_vers = 'V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim#natsoft.com.my). All rights reserved. Released BSD & LGPL.'; /** * Determines whether recordset->RecordCount() is used. @@ -300,6 +304,13 @@ die('Virtual Class -- cannot instantiate'); } + function Version() + { + global $ADODB_vers; + + return (float) substr($ADODB_vers,1); + } + /** Get server version info... @@ -339,7 +350,7 @@ if (isset($HTTP_SERVER_VARS['HTTP_USER_AGENT'])) echo $msg; else echo strip_tags($msg); - if (!empty($ADODB_FLUSH) && ob_get_length() !== false) flush(); // dp not flush if output buffering enabled - useless - thx to Jesse Mullan + if (!empty($ADODB_FLUSH) && ob_get_length() !== false) flush(); // do not flush if output buffering enabled - useless - thx to Jesse Mullan } @@ -370,30 +381,24 @@ if ($argDatabaseName != "") $this->database = $argDatabaseName; $this->_isPersistentConnection = false; - if ($fn = $this->raiseErrorFn) { - if ($forceNew) { - if ($this->_nconnect($this->host, $this->user, $this->password, $this->database)) return true; - } else { - if ($this->_connect($this->host, $this->user, $this->password, $this->database)) return true; - } - $err = $this->ErrorMsg(); - if (empty($err)) $err = "Connection error to server '$argHostname' with user '$argUsername'"; - $fn($this->databaseType,'CONNECT',$this->ErrorNo(),$err,$this->host,$this->database,$this); + if ($forceNew) { + if ($this->_nconnect($this->host, $this->user, $this->password, $this->database)) return true; } else { - if ($forceNew) { - if ($this->_nconnect($this->host, $this->user, $this->password, $this->database)) return true; - } else { - if ($this->_connect($this->host, $this->user, $this->password, $this->database)) return true; - } + if ($this->_connect($this->host, $this->user, $this->password, $this->database)) return true; } - if ($this->debug) ADOConnection::outp( $this->host.': '.$this->ErrorMsg()); + $err = $this->ErrorMsg(); + if (empty($err)) $err = "Connection error to server '$argHostname' with user '$argUsername'"; + if ($fn = $this->raiseErrorFn) + $fn($this->databaseType,'CONNECT',$this->ErrorNo(),$err,$this->host,$this->database,$this); + + if ($this->debug) ADOConnection::outp( $this->host.': '.$err); return false; } - function _nconnect($argHostname, $argUsername, $argPassword, $argDatabaseName) - { - return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabaseName); - } + function _nconnect($argHostname, $argUsername, $argPassword, $argDatabaseName) + { + return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabaseName); + } /** @@ -432,16 +437,16 @@ if ($argDatabaseName != "") $this->database = $argDatabaseName; $this->_isPersistentConnection = true; - + if ($this->_pconnect($this->host, $this->user, $this->password, $this->database)) return true; + $err = $this->ErrorMsg(); + if (empty($err)) { + $err = "Connection error to server '$argHostname' with user '$argUsername'"; + } if ($fn = $this->raiseErrorFn) { - if ($this->_pconnect($this->host, $this->user, $this->password, $this->database)) return true; - $err = $this->ErrorMsg(); - if (empty($err)) $err = "Connection error to server '$argHostname' with user '$argUsername'"; $fn($this->databaseType,'PCONNECT',$this->ErrorNo(),$err,$this->host,$this->database,$this); - } else - if ($this->_pconnect($this->host, $this->user, $this->password, $this->database)) return true; - - if ($this->debug) ADOConnection::outp( $this->host.': '.$this->ErrorMsg()); + } + + if ($this->debug) ADOConnection::outp( $this->host.': '.$err); return false; } @@ -679,6 +684,7 @@ $this->transOff = 1; } + /** Used together with StartTrans() to end a transaction. Monitors connection for sql errors, and will commit or rollback as appropriate. @@ -750,7 +756,7 @@ } if ($inputarr && is_array($inputarr)) { $element0 = reset($inputarr); - # is_object check is because oci8 descriptors can be passed in + # is_object check because oci8 descriptors can be passed in $array_2d = is_array($element0) && !is_object(reset($element0)); if (!is_array($sql) && !$this->_bindInputArray) { @@ -786,8 +792,9 @@ $ret =& $this->_Execute($stmt,$arr); if (!$ret) return $ret; } - } else + } else { $ret =& $this->_Execute($sql,$inputarr); + } } } else { $ret =& $this->_Execute($sql,false); @@ -863,6 +870,8 @@ if ($this->_queryID === true) { // return simplified empty recordset for inserts/updates/deletes with lower overhead $rs =& new ADORecordSet_empty(); + #if (is_array($sql)) $rs->sql = $sql[0]; + #else $rs->sql = $sql; return $rs; } @@ -875,7 +884,6 @@ else $rs->sql = $sql; if ($rs->_numOfRows <= 0) { global $ADODB_COUNTRECS; - if ($ADODB_COUNTRECS) { if (!$rs->EOF){ $rs = &$this->_rs2rs($rs,-1,-1,!is_array($sql)); @@ -1169,6 +1177,7 @@ for ($i=0, $max=$rs->FieldCount(); $i < $max; $i++) { $flds[] = $rs->FetchField($i); } + $arr =& $rs->GetArrayLimit($nrows,$offset); //print_r($arr); if ($close) $rs->Close(); @@ -1328,6 +1337,11 @@ } function &CacheGetAll($secs2cache,$sql=false,$inputarr=false) + { + return $this->CacheGetArray($secs2cache,$sql,$inputarr); + } + + function &CacheGetArray($secs2cache,$sql=false,$inputarr=false) { global $ADODB_COUNTRECS; @@ -1482,18 +1496,29 @@ * - database type (oci8, ibase, ifx, etc) * - database name * - userid + * - setFetchMode (adodb 4.23) * - * We create 256 sub-directories in the cache directory ($ADODB_CACHE_DIR). + * When not in safe mode, we create 256 sub-directories in the cache directory ($ADODB_CACHE_DIR). * Assuming that we can have 50,000 files per directory with good performance, * then we can scale to 12.8 million unique cached recordsets. Wow! */ function _gencachename($sql,$createdir) { global $ADODB_CACHE_DIR; + static $notSafeMode; - $m = md5($sql.$this->databaseType.$this->database.$this->user); - $dir = $ADODB_CACHE_DIR.'/'.substr($m,0,2); - if ($createdir && !file_exists($dir)) { + if ($this->fetchMode === false) { + global $ADODB_FETCH_MODE; + $mode = $ADODB_FETCH_MODE; + } else { + $mode = $this->fetchMode; + } + $m = md5($sql.$this->databaseType.$this->database.$this->user.$mode); + + if (!isset($notSafeMode)) $notSafeMode = !ini_get('safe_mode'); + $dir = ($notSafeMode) ? $ADODB_CACHE_DIR.'/'.substr($m,0,2) : $ADODB_CACHE_DIR; + + if ($createdir && $notSafeMode && !file_exists($dir)) { $oldu = umask(0); if (!mkdir($dir,0771)) if ($this->debug) ADOConnection::outp( "Unable to mkdir $dir for $sql"); @@ -1599,9 +1624,12 @@ * * "Jonathan Younger" */ - function GetUpdateSQL(&$rs, $arrFields,$forceUpdate=false,$magicq=false) + function GetUpdateSQL(&$rs, $arrFields,$forceUpdate=false,$magicq=false,$forcenulls=null) { global $ADODB_INCLUDED_LIB; + if (!isset($forcenulls)) { + $forcenulls = defined('ADODB_FORCE_NULLS') ? true : false; + } if (empty($ADODB_INCLUDED_LIB)) include_once(ADODB_DIR.'/adodb-lib.inc.php'); return _adodb_getupdatesql($this,$rs,$arrFields,$forceUpdate,$magicq); } @@ -1615,9 +1643,12 @@ * Note: This function should only be used on a recordset * that is run against a single table. */ - function GetInsertSQL(&$rs, $arrFields,$magicq=false) + function GetInsertSQL(&$rs, $arrFields,$magicq=false,$forcenulls=null) { global $ADODB_INCLUDED_LIB; + if (!isset($forcenulls)) { + $forcenulls = defined('ADODB_FORCE_NULLS') ? true : false; + } if (empty($ADODB_INCLUDED_LIB)) include_once(ADODB_DIR.'/adodb-lib.inc.php'); return _adodb_getinsertsql($this,$rs,$arrFields,$magicq); } @@ -1744,44 +1775,6 @@ break; } } - - - /** - * $meta contains the desired type, which could be... - * C for character. You will have to define the precision yourself. - * X for teXt. For unlimited character lengths. - * B for Binary - * F for floating point, with no need to define scale and precision - * N for decimal numbers, you will have to define the (scale, precision) yourself - * D for date - * T for timestamp - * L for logical/Boolean - * I for integer - * R for autoincrement counter/integer - * and if you want to use double-byte, add a 2 to the end, like C2 or X2. - * - * - * @return the actual type of the data or false if no such type available - */ - function ActualType($meta) - { - switch($meta) { - case 'C': - case 'X': - return 'VARCHAR'; - case 'B': - - case 'D': - case 'T': - case 'L': - - case 'R': - - case 'I': - case 'N': - return false; - } - } /** @@ -1978,15 +1971,18 @@ * * @return array of column names for current table. */ - function &MetaColumnNames($table) + function &MetaColumnNames($table, $numIndexes=false) { $objarr =& $this->MetaColumns($table); if (!is_array($objarr)) return false; $arr = array(); - foreach($objarr as $v) { - $arr[strtoupper($v->name)] = $v->name; - } + if ($numIndexes) { + $i = 0; + foreach($objarr as $v) $arr[$i++] = $v->name; + } else + foreach($objarr as $v) $arr[strtoupper($v->name)] = $v->name; + return $arr; } @@ -2058,6 +2054,7 @@ */ function UnixDate($v) { + if (is_numeric($v) && strlen($v) !== 8) return $v; if (!preg_match( "|^([0-9]{4})[-/\.]?([0-9]{1,2})[-/\.]?([0-9]{1,2})|", ($v), $rr)) return false; @@ -2097,16 +2094,17 @@ * @return a date formated as user desires */ - function UserDate($v,$fmt='Y-m-d') + function UserDate($v,$fmt='Y-m-d',$gmt=false) { $tt = $this->UnixDate($v); + // $tt == -1 if pre TIMESTAMP_FIRST_YEAR if (($tt === false || $tt == -1) && $v != false) return $v; else if ($tt == 0) return $this->emptyDate; else if ($tt == -1) { // pre-TIMESTAMP_FIRST_YEAR } - return adodb_date($fmt,$tt); + return ($gmt) ? adodb_gmdate($fmt,$tt) : adodb_date($fmt,$tt); } @@ -2117,21 +2115,21 @@ * * @return a timestamp formated as user desires */ - function UserTimeStamp($v,$fmt='Y-m-d H:i:s') + function UserTimeStamp($v,$fmt='Y-m-d H:i:s',$gmt=false) { # strlen(14) allows YYYYMMDDHHMMSS format - if (is_numeric($v) && strlen($v)<14) return adodb_date($fmt,$v); + if (is_numeric($v) && strlen($v)<14) return ($gmt) ? adodb_gmdate($fmt,$v) : adodb_date($fmt,$v); $tt = $this->UnixTimeStamp($v); // $tt == -1 if pre TIMESTAMP_FIRST_YEAR if (($tt === false || $tt == -1) && $v != false) return $v; if ($tt == 0) return $this->emptyTimeStamp; - return adodb_date($fmt,$tt); + return ($gmt) ? adodb_gmdate($fmt,$tt) : adodb_date($fmt,$tt); } /** * Quotes a string, without prefixing nor appending quotes. */ - function addq($s,$magicq=false) + function addq($s,$magic_quotes=false) { if (!$magic_quotes) { @@ -2210,9 +2208,9 @@ { global $ADODB_INCLUDED_LIB; if (empty($ADODB_INCLUDED_LIB)) include_once(ADODB_DIR.'/adodb-lib.inc.php'); - if ($this->pageExecuteCountRows) return _adodb_pageexecute_all_rows($this, $sql, $nrows, $page, $inputarr, $secs2cache); - return _adodb_pageexecute_no_last_page($this, $sql, $nrows, $page, $inputarr, $secs2cache); - + if ($this->pageExecuteCountRows) $rs =& _adodb_pageexecute_all_rows($this, $sql, $nrows, $page, $inputarr, $secs2cache); + else $rs =& _adodb_pageexecute_no_last_page($this, $sql, $nrows, $page, $inputarr, $secs2cache); + return $rs; } @@ -2275,6 +2273,7 @@ function Close(){return true;} function FetchRow() {return false;} function FieldCount(){ return 0;} + function Init() {} } //============================================================================================== @@ -2581,7 +2580,6 @@ else if ($tt == -1) { // pre-TIMESTAMP_FIRST_YEAR } return adodb_date($fmt,$tt); - } @@ -2592,11 +2590,12 @@ */ function UnixDate($v) { - + if (is_numeric($v) && strlen($v) !== 8) return $v; if (!preg_match( "|^([0-9]{4})[-/\.]?([0-9]{1,2})[-/\.]?([0-9]{1,2})|", ($v), $rr)) return false; - if ($rr[1] <= TIMESTAMP_FIRST_YEAR) return 0; + if ($rr[1] <= TIMESTAMP_FIRST_YEAR || $rr[1] > 10000) return 0; + // h-m-s-MM-DD-YY return @adodb_mktime(0,0,0,$rr[2],$rr[3],$rr[1]); } @@ -2806,7 +2805,7 @@ /** * Use associative array to get fields array for databases that do not support - * associative arrays. Submitted by Paolo S. Asioli paolo.asioli@libero.it + * associative arrays. Submitted by Paolo S. Asioli paolo.asioli#libero.it * * If you don't want uppercase cols, set $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC * before you execute your SQL statement, and access $rs->fields['col'] directly. @@ -2929,7 +2928,7 @@ * Get the ADOFieldObjects of all columns in an array. * */ - function FieldTypesArray() + function& FieldTypesArray() { $arr = array(); for ($i=0, $max=$this->_numOfFields; $i < $max; $i++) @@ -3029,10 +3028,10 @@ * additional info (eg. primary_key for mysql). * * @return the general type of the data: - * C for character < 200 chars - * X for teXt (>= 200 chars) + * C for character < 250 chars + * X for teXt (>= 250 chars) * B for Binary - * N for numeric floating point + * N for numeric or floating point * D for date * T for timestamp * L for logical/Boolean @@ -3314,8 +3313,10 @@ /* Use associative array to get fields array */ function Fields($colname) { - if ($this->fetchMode & ADODB_FETCH_ASSOC) return $this->fields[$colname]; - + if ($this->fetchMode & ADODB_FETCH_ASSOC) { + if (!isset($this->fields[$colname])) $colname = strtolower($colname); + return $this->fields[$colname]; + } if (!$this->bind) { $this->bind = array(); for ($i=0; $i < $this->_numOfFields; $i++) { @@ -3424,6 +3425,7 @@ $ok = class_exists("ADODB_" . $db); if ($ok) return $db; + print_r(get_declared_classes()); $file = ADODB_DIR."/drivers/adodb-".$db.".inc.php"; if (!file_exists($file)) ADOConnection::outp("Missing file: $file"); else ADOConnection::outp("Syntax error in file: $file"); @@ -3550,7 +3552,7 @@ $dict->connection = &$conn; $dict->upperName = strtoupper($drivername); $dict->quote = $conn->nameQuote; - if (is_resource($conn->_connectionID)) + if (!empty($conn->_connectionID)) $dict->serverInfo = $conn->ServerInfo(); return $dict; diff --git a/phpgwapi/inc/adodb/datadict/datadict-access.inc.php b/phpgwapi/inc/adodb/datadict/datadict-access.inc.php index daef9425eb..b1908b1b1d 100644 --- a/phpgwapi/inc/adodb/datadict/datadict-access.inc.php +++ b/phpgwapi/inc/adodb/datadict/datadict-access.inc.php @@ -1,7 +1,7 @@ connection) ) { + return $name; + } + + $quote = $this->connection->nameQuote; + + // if name is of the form `name`, quote it + if ( preg_match('/^`(.+)`$/', $name, $matches) ) { + return $quote . $matches[1] . $quote; + } + + // if name contains special characters, quote it + if ( !preg_match('/^[' . $this->nameRegex . ']+$/', $name) ) { + return $quote . $name . $quote; + } + + return $quote . $name . $quote; + } + + function CreateDatabase($dbname, $options=false) + { + $options = $this->_Options($options); + $sql = array(); + + $sql[] = "DECLARE EXTERNAL FUNCTION LOWER CSTRING(80) RETURNS CSTRING(80) FREE_IT ENTRY_POINT 'IB_UDF_lower' MODULE_NAME 'ib_udf'"; + + return $sql; + } + + function _DropAutoIncrement($t) + { + if (strpos($t,'.') !== false) { + $tarr = explode('.',$t); + return 'DROP GENERATOR '.$tarr[0].'."gen_'.$tarr[1].'"'; + } + return 'DROP GENERATOR "GEN_'.$t; + } + + + function _CreateSuffix($fname,$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned) + { + $suffix = ''; + + if (strlen($fdefault)) $suffix .= " DEFAULT $fdefault"; + if ($fnotnull) $suffix .= ' NOT NULL'; + if ($fautoinc) $this->seqField = $fname; + if ($fconstraint) $suffix .= ' '.$fconstraint; + + return $suffix; + } + +/* +CREATE or replace TRIGGER jaddress_insert +before insert on jaddress +for each row +begin +IF ( NEW."seqField" IS NULL OR NEW."seqField" = 0 ) THEN + NEW."seqField" = GEN_ID("GEN_tabname", 1); +end; +*/ + function _Triggers($tabname,$tableoptions) + { + if (!$this->seqField) return array(); + + $tab1 = preg_replace( '/"/', '', $tabname ); + if ($this->schema) { + $t = strpos($tab1,'.'); + if ($t !== false) $tab = substr($tab1,$t+1); + else $tab = $tab1; + $seqField = $this->seqField; + $seqname = $this->schema.'.'.$this->seqPrefix.$tab; + $trigname = $this->schema.'.trig_'.$this->seqPrefix.$tab; + } else { + $seqField = $this->seqField; + $seqname = $this->seqPrefix.$tab1; + $trigname = 'trig_'.$seqname; + } + if (isset($tableoptions['REPLACE'])) + { $sql[] = "DROP GENERATOR \"$seqname\""; + $sql[] = "CREATE GENERATOR \"$seqname\""; + $sql[] = "ALTER TRIGGER \"$trigname\" BEFORE INSERT OR UPDATE AS BEGIN IF ( NEW.$seqField IS NULL OR NEW.$seqField = 0 ) THEN NEW.$seqField = GEN_ID(\"$seqname\", 1); END"; + } + else + { $sql[] = "CREATE GENERATOR \"$seqname\""; + $sql[] = "CREATE TRIGGER \"$trigname\" FOR $tabname BEFORE INSERT OR UPDATE AS BEGIN IF ( NEW.$seqField IS NULL OR NEW.$seqField = 0 ) THEN NEW.$seqField = GEN_ID(\"$seqname\", 1); END"; + } + + $this->seqField = false; + return $sql; + } + +} + + +?> \ No newline at end of file diff --git a/phpgwapi/inc/adodb/datadict/datadict-generic.inc.php b/phpgwapi/inc/adodb/datadict/datadict-generic.inc.php index d2e5f4a0dd..30c4e66c1b 100644 --- a/phpgwapi/inc/adodb/datadict/datadict-generic.inc.php +++ b/phpgwapi/inc/adodb/datadict/datadict-generic.inc.php @@ -1,7 +1,7 @@ \ No newline at end of file diff --git a/phpgwapi/inc/adodb/datadict/datadict-mysql.inc.php b/phpgwapi/inc/adodb/datadict/datadict-mysql.inc.php index 3af2a178a8..fa8b47b62e 100644 --- a/phpgwapi/inc/adodb/datadict/datadict-mysql.inc.php +++ b/phpgwapi/inc/adodb/datadict/datadict-mysql.inc.php @@ -1,7 +1,7 @@ debug) ADOConnection::outp("DropColumnSQL not supported for Oracle"); - return array(); + if (!is_array($flds)) $flds = explode(',',$flds); + $sql = array(); + $s = "ALTER TABLE $tabname DROP("; + $s .= implode(',',$flds).') CASCADE COSTRAINTS'; + $sql[] = $s; + return $sql; } function _DropAutoIncrement($t) @@ -178,14 +186,20 @@ end; if ($t !== false) $tab = substr($tabname,$t+1); else $tab = $tabname; $seqname = $this->schema.'.'.$this->seqPrefix.$tab; - $trigname = $this->schema.'.TRIG_'.$this->seqPrefix.$tab; + $trigname = $this->schema.'.'.$this->trigPrefix.$this->seqPrefix.$tab; } else { $seqname = $this->seqPrefix.$tabname; - $trigname = "TRIG_$seqname"; + $trigname = $this->trigPrefix.$seqname; } if (isset($tableoptions['REPLACE'])) $sql[] = "DROP SEQUENCE $seqname"; - $sql[] = "CREATE SEQUENCE $seqname"; - $sql[] = "CREATE OR REPLACE TRIGGER $trigname BEFORE insert ON $tabname FOR EACH ROW BEGIN select $seqname.nextval into :new.$this->seqField from dual; END;"; + $seqCache = ''; + if (isset($tableoptions['SEQUENCE_CACHE'])){$seqCache = $tableoptions['SEQUENCE_CACHE'];} + $seqIncr = ''; + if (isset($tableoptions['SEQUENCE_INCREMENT'])){$seqIncr = ' INCREMENT BY '.$tableoptions['SEQUENCE_INCREMENT'];} + $seqStart = ''; + if (isset($tableoptions['SEQUENCE_START'])){$seqIncr = ' START WITH '.$tableoptions['SEQUENCE_START'];} + $sql[] = "CREATE SEQUENCE $seqname $seqStart $seqIncr $seqCache"; + $sql[] = "CREATE OR REPLACE TRIGGER $trigname BEFORE insert ON $tabname FOR EACH ROW WHEN (NEW.$this->seqField IS NULL OR NEW.$this->seqField = 0) BEGIN select $seqname.nextval into :new.$this->seqField from dual; END;"; $this->seqField = false; return $sql; diff --git a/phpgwapi/inc/adodb/datadict/datadict-postgres.inc.php b/phpgwapi/inc/adodb/datadict/datadict-postgres.inc.php index fba038b3e2..a809472e7a 100644 --- a/phpgwapi/inc/adodb/datadict/datadict-postgres.inc.php +++ b/phpgwapi/inc/adodb/datadict/datadict-postgres.inc.php @@ -1,7 +1,7 @@

ADOdb Library for PHP

-

V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim#natsoft.com)

+

V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim#natsoft.com)

This software is dual licensed using BSD-Style and LGPL. This means you can use it in compiled proprietary and commercial products.

-

Useful ADOdb links: Download   Other Docs + + +
Kindly note that the ADOdb home page has moved to http://adodb.sourceforge.net/ because of the persistent + unreliability of http://php.weblogs.com. Please change your links!
+

Useful ADOdb links: Download   Other Docs

Introduction
Unique Features
@@ -181,7 +185,7 @@ visit http://php.weblog

Feature requests and bug reports can be emailed to jlim#natsoft.com.my or posted to the ADOdb Help forums at http://phplens.com/lens/lensforum/topics.php?id=4.

Installation Guide

-

Make sure you are running PHP 4.0.4 or later. +

Make sure you are running PHP 4.0.5 or later. Unpack all the files into a directory accessible by your webserver.

To test, try modifying some of the tutorial examples. Make sure you customize the connection settings correctly. You can debug using $db->debug = true as shown below:

@@ -244,6 +248,7 @@ PHP will share the same connection. This can cause problems if the connections a different databases. The solution is to always use different userid's for different databases, or use NConnect(). +

Examples of Connecting to Databases

MySQL and Most Other Database Drivers

MySQL connections are very straightforward, and the parameters are identical @@ -262,7 +267,7 @@ different databases. The solution is to always use different userid's for differ

b. the classical 4 parameters:

 	$conn->PConnect('localhost','userid','password','database');
- 
+

LDAP

Here is an example of querying a LDAP server. Thanks to Josh Eldridge for the driver and this example:

@@ -295,10 +300,8 @@ if ($rs)
 		$rs->MoveNext();
 	} 
 	
-$rs = $ldap->Execute( $filter );
 print_r( $ldap->GetArray( $filter ) );
 
-$rs = $ldap->Execute( $filter );
 print_r( $ldap->GetRow( $filter ) );
 
 $ldap->Close();
@@ -311,30 +314,35 @@ You define the database in the $host parameter:
 	$conn->PConnect('localhost:c:\ibase\employee.gdb','sysdba','masterkey');
 

SQLite

-Sqlite will create database if it does not exist. +Sqlite will create the database file if it does not exist.
 	$conn = &ADONewConnection('sqlite'); 
 	$conn->PConnect('c:\path\to\sqlite.db'); # sqlite will create if does not exist
 
-

Oracle

-

With Oracle, you can connect in multiple ways.

+

Oracle (oci8)

+

With oci8, you can connect in multiple ways. Note that oci8 works fine with +newer versions of the Oracle, eg. 9i and 10g.

a. PHP and Oracle reside on the same machine, use default SID.

	$conn->Connect(false, 'scott', 'tiger');
-

b. TNS Name defined, eg. 'myTNS'

-
	$conn->PConnect(false, 'scott', 'tiger', 'myTNS');
-
+

b. TNS Name defined in tnsnames.ora (or ONAMES or HOSTNAMES), eg. 'myTNS'

+
	$conn->PConnect(false, 'scott', 'tiger', 'myTNS');

or

 	$conn->PConnect('myTNS', 'scott', 'tiger');

c. Host Address and SID

	$conn->Connect('192.168.0.1', 'scott', 'tiger', 'SID');

d. Host Address and Service Name

	$conn->Connect('192.168.0.1', 'scott', 'tiger', 'servicename');
+

e. Oracle connection string: +

	$cstr = "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=$host)(PORT=$port))
+			(CONNECT_DATA=(SID=$sid)))";
+	$conn->Connect($cstr, 'scott', 'tiger');
+

DSN-less ODBC (access and mssql examples)

ODBC DSN's can be created in the ODBC control panel, or you can use a DSN-less connection.To use DSN-less connections with ODBC you need PHP 4.3 or later.

-

For Microsoft Access:

+

For Microsoft Access:

 	$db =& ADONewConnection('access');
 	$dsn = "Driver={Microsoft Access Driver (*.mdb)};Dbq=d:\\northwind.mdb;Uid=Admin;Pwd=;";
@@ -346,6 +354,11 @@ For Microsoft SQL Server:
 	$dsn = "Driver={SQL Server};Server=localhost;Database=northwind;";
 	$db->Connect($dsn,'userid','password');
 
+or if you prefer to use the mssql extension (which is limited to mssql 6.5 functionality): +
+	$db =& ADONewConnection('mssql');
+	$db->Execute("localhost', 'userid', 'password', 'northwind');
+
DSN-less Connections with ADO
If you are using versions of PHP earlier than PHP 4.3.0, DSN-less connections only work with Microsoft's ADO, which is Microsoft's COM based API. An example @@ -385,7 +398,7 @@ using the ADOdb library and Microsoft's ADO:

The fastest way to access the fields is by accessing the array $recordset->fields directly. Also set the global variables $ADODB_FETCH_MODE = ADODB_FETCH_NUM, and (for oci8, ibase/firebird and odbc) $ADODB_COUNTRECS = false - before you connect to your database. At the time of writing (Dec 2003).

+ before you connect to your database.

Consider using bind parameters if your database supports it, as it improves query plan reuse. Use ADOdb's performance tuning system to identify bottlenecks quickly. At the time of writing (Dec 2003), this means oci8 and odbc drivers.

@@ -470,6 +483,8 @@ catch exceptions on errors as they occur.

Note that reaching EOF is not considered an error nor an exception.

Databases Supported

+The name below is the value you pass to NewADOConnection($name) to create a connection object for that database. +

@@ -572,19 +587,11 @@ catch exceptions on errors as they occur. - - - - - - - - + - + @@ -637,7 +644,7 @@ catch exceptions on errors as they occur. - + @@ -799,11 +806,26 @@ catch exceptions on errors as they occur. - + + + + + + + + + + + @@ -1096,6 +1118,10 @@ $conn->Execute($updateSQL); # Update the record in the database $conn->Close(); ?> +GetInsertSQL/GetUpdateSQL ignore all empty fields (they are not added to the SQL generated). +To explicitly force a field to be set to "null", set the constant define('ADODB_FORCE_NULLS',1) before +you call the functions. +

Example 8: Implementing Scrolling with Next and Previous

The following code creates a very simple recordset pager, where you can scroll from page to page of a recordset.

@@ -1373,12 +1399,38 @@ PEAR::setErrorHandling('PEAR_ERROR_DIE'); $databasename = 'xphplens'; $driver = 'mysql'; $dsn = "$driver://$username:$password@$hostname/$databasename"; -
   $db = DB::Connect($dsn);
$rs = $db->Execute('select firstname,lastname from adoxyz'); +
   $db = DB::Connect($dsn);
$rs = $db->query('select firstname,lastname from adoxyz'); $cnt = 0; - while ($arr = $rs->FetchRow()) { + while ($arr = $rs->fetchRow()) { print_r($arr); print "<br>"; }

This requires PEAR to be installed and in the default include path in php.ini.

+

PEAR Compatibility

+ We support DSN's (see above), and the following functions: +
+ DB_Common
+ 	query - returns PEAR_Error on error
+	limitQuery - return PEAR_Error on error
+	prepare - does not return PEAR_Error on error
+	execute - does not return PEAR_Error on error
+	setFetchMode - supports ASSOC and ORDERED
+	errorNative
+	quote
+	nextID
+	disconnect
+	
+	getOne
+	getAssoc
+	getRow
+	getCol
+	
+ DB_Result
+ 	numRows - returns -1 if not supported
+	numCols
+	fetchInto - does not support passing of fetchmode
+	fetchRows - does not support passing of fetchmode
+	free
+

Caching of Recordsets

ADOdb now supports caching of recordsets using the CacheExecute( ), CachePageExecute( ) and CacheSelectLimit( ) functions. There are similar to the non-cache functions, @@ -1407,7 +1459,8 @@ $rs = $conn->CacheExec $rs = $conn->CacheExecute('select * from table');

Please note that magic_quotes_runtime should be turned off. More - info. + info, and do not change $ADODB_FETCH_MODE (or SetFetchMode) + as the cached recordset will use the $ADODB_FETCH_MODE set when the query was executed.

Pivot Tables

Since ADOdb 2.30, we support the generation of SQL to create pivot tables, also known as cross-tabulations. For further explanation @@ -1700,7 +1753,7 @@ in adodb/lang/adodb-$lang.inc.php, where $lang is the supported langauge.

Non-persistent connect to data source or server $host, using userid $user and password $password. If the server supports multiple databases, connect to database $database.

-

Returns true/false depending on connection.

+

Returns true/false depending on connection success. Since 4.23, null is returned if the extension is not loaded.

ADO Note: If you are using a Microsoft ADO and not OLEDB, you can set the $database parameter to the OLEDB data provider you are using.

PostgreSQL: An alternative way of connecting to the database is to pass the @@ -1715,8 +1768,10 @@ in adodb/lang/adodb-$lang.inc.php, where $lang is the supported langauge.

 # $oraname in tnsnames.ora/ONAMES/HOSTNAMES
  $conn->Connect(false, 'scott', 'tiger', $oraname); 
  $conn->Connect('server:1521', 'scott', 'tiger', 'ServiceName'); # bypass tnsnames.ora
-

There are many examples of connecting to a database at php.weblogs.com/ADOdb, +

There are many examples of connecting to a database. +See Connection Examples, php.weblogs.com/ADOdb, and in the testdatabases.inc.php file included in the release.

+

PConnect($host,[$user],[$password],[$database])

Persistent connect to data source or server $host, using userid $user and password $password. If the server supports multiple databases, @@ -1724,7 +1779,8 @@ in adodb/lang/adodb-$lang.inc.php, where $lang is the supported langauge.

We now perform a rollback on persistent connection for selected databases since 2.21, as advised in the PHP manual. See change log or source code for which databases are affected. -

Returns true/false depending on connection. See Connect( ) above for more info.

+

Returns true/false depending on connection. Since 4.23, null is returned if the extension is not loaded. +See Connect( ) above for more info.

Since ADOdb 2.21, we also support autoRollback. If you set:

 $conn = &NewADOConnection('mysql');
@@ -1738,6 +1794,8 @@ in adodb/lang/adodb-$lang.inc.php, where $lang is the supported langauge.
 

Since ADOdb 3.11, you can force non-persistent connections even if PConnect is called by defining the constant ADODB_NEVER_PERSIST before you call PConnect. +

+Since 4.23, null is returned if the extension is not loaded.

NConnect($host,[$user],[$password],[$database])

Always force a new connection. In contrast, PHP sometimes reuses connections when you use Connect() or PConnect(). Currently works only on mysql (PHP 4.3.0 @@ -2042,7 +2100,7 @@ $ret = $db->Replace('atable2', array('firstname'=>"'Harun'",'lastname'=>"'Al-Rashid'", 'age' => 'null'), array('lastname','firstname'));

-

GetUpdateSQL(&$rs, $arrFields, $forceUpdate=false,$magicq=false)

+

GetUpdateSQL(&$rs, $arrFields, $forceUpdate=false,$magicq=false, $forcenulls=false)

Generate SQL to update a table given a recordset $rs, and the modified fields of the array $arrFields (which must be an associative array holding the column names and the new values) are compared with the current recordset. If $forceUpdate @@ -2051,15 +2109,19 @@ $ret = $db->Replace('atable2', to indicate whether magic quotes are enabled (see qstr()). The field names in the array are case-insensitive.

Since 3.61, define('ADODB_FORCE_NULLS',1) and all PHP nulls will be auto-converted to SQL nulls. -

GetInsertSQL(&$rs, $arrFields,$magicq=false)

+ Since 4.24, we allow you to pass in $forcenulls as a parameter. This overrides the ADODB_FORCE_NULLS + constant. +

GetInsertSQL(&$rs, $arrFields,$magicq=false,$forcenulls=false)

Generate SQL to insert into a table given a recordset $rs. Requires the query to be associative. $magicq is used to indicate whether magic quotes are enabled (for qstr()). The field names in the array are case-insensitive.

- +

+ Since 2.42, you can pass a table name instead of a recordset into +GetInsertSQL (in $rs), and it will generate an insert statement for that table.

Since 3.61, define('ADODB_FORCE_NULLS',1) and all PHP nulls will be auto-converted to SQL nulls. - Since ADOdb 2.42, you can pass a table name instead of a recordset into -GetInsertSQL (in $rs), and it will generate an insert statement for that table. +Since 4.24, we allow you to pass in $forcenulls as a parameter. This overrides the ADODB_FORCE_NULLS + constant.

PageExecute($sql, $nrows, $page, $inputarr=false)

Used for pagination of recordset. $page is 1-based. See Example 8.

@@ -2608,9 +2670,9 @@ printf("<p>Total queries=%d; total cached=%d</p>",$EXECS+$ (required for some databases).

For schema support, pass in the $table parameter, "$schema.$tablename". This is only supported for selected databases. -

MetaColumnNames($table)

+

MetaColumnNames($table,$numericIndex=false)

Returns an array of column names for $table. Since ADOdb 4.22, this is an associative array, with the -keys in uppercase. +keys in uppercase. Set $numericIndex=true if you want the old behaviour of numeric indexes (since 4.23).

e.g. array('FIELD1' => 'Field1', 'FIELD2'=>'Field2')

@@ -3082,7 +3144,97 @@ $rs = $conn->Execute PHP.

Change Log

-

4.?? 2004 +

4.50 6 July 2004 +

Bumped it to 4.50 to avoid confusion with PHP 4.3.x series. +

Added alpha PDO driver. Very buggy, only works with odbc. +

Tested mysqli. Set poorAffectedRows = true. Cleaned up movenext() and _fetch(). +

PageExecute does not work properly with php5 (return val not a variable). Reported Dmytro Sychevsky sych#php.com.ua. Fixed. +

MetaTables() for mysql, $showschema parameter was not backward compatible with older versions of adodb. Fixed. +

Changed mysql GetOne() to work with mysql 3.23 when using with non-select stmts (e.g. SHOW TABLES). +

Changed TRIG_ prefix to a variable in datadict-oci8.inc.php. Thx to Luca.Gioppo#csi.it. +

New to adodb-time code. We allow you to define your own daylights savings function, +adodb_daylight_sv for pre-1970 dates. If the function is defined +(somewhere in an include), then you can correct +for daylights savings. See http://phplens.com/phpeverywhere/node/view/16#daylightsavings +for more info. +

New sqlitepo driver. This is because assoc mode does not work like other drivers in sqlite. + Namely, when selecting (joining) multiple tables, in assoc mode the table + names are included in the assoc keys in the "sqlite" driver. + In "sqlitepo" driver, the table names are stripped from the returned column names. + When this results in a conflict, the first field get preference. + Contributed by Herman Kuiper herman#ozuzo.net +

Added $forcenull parameter to GetInsertSQL/GetUpdateSQL. Idea by Marco Aurelio Silva. +

More XHTML changes for GetMenu. By Jeremy Evans. +

Fixes some ibase date issues. Thx to stefan bogdan. +

Improvements to mysqli driver to support $ADODB_COUNTRECS. +

Fixed adodb-csvlib.inc.php problem when reading stream from socket. We need to poll stream continiously. +

4.23 16 June 2004 +

+New interbase/firebird fixes thx to Lester Caine. +Driver fixes a problem with getting field names in the result array, and +corrects a couple of data conversions. Also we default to dialect3 for firebird. +Also ibase sysDate property was wrong. Changed to cast as timestamp. +

+The datadict driver is set up to give quoted tables and fields as this +was the only way round reserved words being used as field names in +TikiWiki. TikiPro is tidying that up, and I hope to be able to produce a +build of THAT which uses what I consider proper UPPERCASE field and +table names. The conversion of TikiWiki to ADOdb helped in that, but +until the database is completely tidied up in TikiPro ... +

Modified _gencachename() to include fetchmode in name hash. +This means you should clear your cache directory after installing this release as the +cache name algorithm has changed. +

Now Cache* functions work in safe mode, because we do not create sub-directories in the $ADODB_CACHE_DIR in safe mode. In non-safe mode we still create sub-directories. Done by modifying _gencachename(). +

Added $gmt parameter (true/false) to UserDate and UserTimeStamp in connection class, to force conversion of input (in local time) to be converted to UTC/GMT. +

Mssql datadict did not support INT types properly (no size param allowed). +Added _GetSize() to datadict-mssql.inc.php. +

For borland_ibase, BeginTrans(), changed:
+

   $this->_transactionID = $this->_connectionID;
+to
+
   $this->_transactionID = ibase_trans($this->ibasetrans, $this->_connectionID);
+ +

Fixed typo in mysqi_field_seek(). Thx to Sh4dow (sh4dow#php.pl). +

LogSQL did not work with Firebird/Interbase. Fixed. +

Postgres: made errorno() handling more consistent. Thx to Michael Jahn, Michael.Jahn#mailbox.tu-dresden.de. +

Added informix patch to better support metatables, metacolumns by "Cecilio Albero" c-albero#eos-i.com +

Cyril Malevanov contributed patch to oci8 to support passing of LOB parameters: +

+	$text = 'test test test';
+	$sql = "declare rs clob; begin :rs := lobinout(:sa0); end;";
+	$stmt = $conn -> PrepareSP($sql);
+	$conn -> InParameter($stmt,$text,'sa0', -1, OCI_B_CLOB);
+	$rs = '';
+	$conn -> OutParameter($stmt,$rs,'rs', -1, OCI_B_CLOB);
+	$conn -> Execute($stmt);
+	echo "return = ".$rs."<br>";
+
+As he says, the LOBs limitations are: +
+ - use OCINewDescriptor before binding
+ - if Param is IN, uses save() before each execute. This is done automatically for you.
+ - if Param is OUT, uses load() after each execute. This is done automatically for you.
+ - when we bind $var as LOB, we create new descriptor and return it as a
+   Bind Result, so if we want to use OUT parameters, we have to store
+   somewhere &$var to load() data from LOB to it.
+ - IN OUT params are not working now (should not be a big problem to fix it)
+ - now mass binding not working too (I've wrote about it before)
+
+

Simplified Connect() and PConnect() error handling. +

When extension not loaded, Connect() and PConnect() will return null. On connect error, the fns will return false. +

CacheGetArray() added to code. +

Added Init() to adorecordset_empty(). +

Changed postgres64 driver, MetaColumns() to not strip off quotes in default value if :: detected (type-casting of default). +

Added test: if (!defined('ADODB_DIR')) die(). Useful to prevent hackers from detecting file paths. +

Changed metaTablesSQL to ignore Postgres 7.4 information schemas (sql_*). +

New polish language file by Grzegorz Pacan +

Added support for UNION in _adodb_getcount(). +

Added security check for ADODB_DIR to limit path disclosure issues. Requested by postnuke team. +

Added better error message support to oracle driver. Thx to Gaetano Giunta. +

Added showSchema support to mysql. +

Bind in oci8 did not handle $name=false properly. Fixed. +

If extension not loaded, Connect(), PConnect(), NConnect() will return null. +

4.22 15 Apr 2004 +

Moved docs to own adodb/docs folder.

Fixed session bug when quoting compressed/encrypted data in Replace().

Netezza Driver and LDAP drivers contributed by Josh Eldridge.

GetMenu now uses rtrim() on values instead of trim(). diff --git a/phpgwapi/inc/adodb/docs/docs-datadict.htm b/phpgwapi/inc/adodb/docs/docs-datadict.htm index f2702e44d3..a815749dbb 100644 --- a/phpgwapi/inc/adodb/docs/docs-datadict.htm +++ b/phpgwapi/inc/adodb/docs/docs-datadict.htm @@ -18,9 +18,11 @@

ADOdb Data Dictionary Library for PHP

-

V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim#natsoft.com.my).
AXMLS (c) 2004 ars Cognita, Inc

+

V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim#natsoft.com.my).
AXMLS (c) 2004 ars Cognita, Inc

This software is dual licensed using BSD-Style and LGPL. This means you can use it in compiled proprietary and commercial products.

-

Useful ADOdb links: Download   Other Docs

+
NameInterbase client Unix and Windows
informix72C Informix databases before Informix 7.3 that do no support - SELECT FIRST.Y/NInformix clientUnix and Windows
informix CGeneric informix driver.Generic informix driver. Use this if you are using Informix 7.3 or later. Y/N Informix client Unix and WindowsA MySQL without transaction support. You can also set $db->clientFlags before connecting.Y/NY MySQL client Unix and Windows
sqlite BSQLite. Only tested on PHP5.SQLite. Y -

Unix and Windows.

sqlitepoBPortable SQLite driver. This is because assoc mode does not work like other drivers in sqlite. + Namely, when selecting (joining) multiple tables, the table + names are included in the assoc keys in the "sqlite" driver.

+ In "sqlitepo" driver, the table names are stripped from the returned column names. + When this results in a conflict, the first field get preference. +

Y-

Unix and Windows.

sybase C
Kindly note that the ADOdb home page has moved to http://adodb.sourceforge.net/ because of the persistent + unreliability of http://php.weblogs.com. Please change your links!
+

Useful ADOdb links: Download   Other Docs

This documentation describes a PHP class library to automate the creation of tables, indexes and foreign key constraints portably for multiple databases. Richard Tango-Lowy and Dan Cech @@ -138,7 +140,7 @@ field size. Then optional keywords in $otheroptions:

NAME C(32) CONSTRAINTS 'FOREIGN KEY REFERENCES reftable' "; -

Note that if you have special characters in the field name (e.g. My Date), you should enclose it in back-quotes. Normally field names are not case-sensitive, but if you enclose it in back-quotes, some databases treat the names as case-sensitive, and some don't. So be careful.

+

Note that if you have special characters in the field name (e.g. My Date), you should enclose it in back-quotes. Normally field names are not case-sensitive, but if you enclose it in back-quotes, some databases will treat the names as case-sensitive (eg. Oracle) , and others won't. So be careful.

The $taboptarray is the 3rd parameter of the CreateTableSQL function. This contains table specific settings. Legal keywords include:

    diff --git a/phpgwapi/inc/adodb/docs/docs-perf.htm b/phpgwapi/inc/adodb/docs/docs-perf.htm index eb972e295d..ae2e0c736f 100644 --- a/phpgwapi/inc/adodb/docs/docs-perf.htm +++ b/phpgwapi/inc/adodb/docs/docs-perf.htm @@ -7,10 +7,12 @@

    The ADOdb Performance Monitoring Library

    -

    V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim#natsoft.com.my)

    +

    V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim#natsoft.com.my)

    This software is dual licensed using BSD-Style and LGPL. This means you can use it in compiled proprietary and commercial products.

    -

    Useful ADOdb links: Download   Other Docs +
    Kindly note that the ADOdb home page has moved to http://adodb.sourceforge.net/ because of the persistent + unreliability of http://php.weblogs.com. Please change your links!
    +

    Useful ADOdb links: Download   Other Docs

    Introduction

    This module, part of the ADOdb package, provides both CLI and HTML interfaces for viewing key performance indicators of your database. This is very useful diff --git a/phpgwapi/inc/adodb/docs/docs-session.htm b/phpgwapi/inc/adodb/docs/docs-session.htm index 0a7809b655..96571b81b7 100644 --- a/phpgwapi/inc/adodb/docs/docs-session.htm +++ b/phpgwapi/inc/adodb/docs/docs-session.htm @@ -11,10 +11,12 @@

    ADODB Session Management Manual

    -V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim#natsoft.com.my) +V4.50 6 July 2004 (c) 2000-2004 John Lim (jlim#natsoft.com.my)

    This software is dual licensed using BSD-Style and LGPL. This means you can use it in compiled proprietary and commercial products. -

    Useful ADOdb links: Download   Other Docs +
    Kindly note that the ADOdb home page has moved to http://adodb.sourceforge.net/ because of the persistent + unreliability of http://php.weblogs.com. Please change your links!
    +

    Useful ADOdb links: Download   Other Docs

    Introduction

    diff --git a/phpgwapi/inc/adodb/docs/tips_portable_sql.htm b/phpgwapi/inc/adodb/docs/tips_portable_sql.htm index 2670423331..2d08bbb1be 100644 --- a/phpgwapi/inc/adodb/docs/tips_portable_sql.htm +++ b/phpgwapi/inc/adodb/docs/tips_portable_sql.htm @@ -17,7 +17,7 @@ Dimension in my Mac days, to the databases I currently use, which are: Oracle, FoxPro, Access, MS SQL Server and MySQL. Although most of the advice here applies to using SQL with Perl, Python and other programming languages, I will focus on PHP and how - the ADOdb database abstraction library + the ADOdb database abstraction library offers some solutions.

    Most database vendors practice product lock-in. The best or fastest way to do things is often implemented using proprietary extensions to SQL. This makes diff --git a/phpgwapi/inc/adodb/drivers/adodb-access.inc.php b/phpgwapi/inc/adodb/drivers/adodb-access.inc.php index ebaaf810bd..9a3f200a8c 100644 --- a/phpgwapi/inc/adodb/drivers/adodb-access.inc.php +++ b/phpgwapi/inc/adodb/drivers/adodb-access.inc.php @@ -1,16 +1,18 @@ ADODB_ado(); + $this->ADODB_ado(); } function _insertid() { - return $this->GetOne('select @@identity'); + return $this->GetOne('select @@identity'); } function _affectedrows() { - return $this->GetOne('select @@rowcount'); + return $this->GetOne('select @@rowcount'); } -} - -class ADORecordSet_ado_mssql extends ADORecordSet_ado { + 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(); + } + + return $arr; + } + } + + class ADORecordSet_ado_mssql extends ADORecordSet_ado { var $databaseType = 'ado_mssql'; function ADORecordSet_ado_mssql($id,$mode=false) { - return $this->ADORecordSet_ado($id,$mode); + return $this->ADORecordSet_ado($id,$mode); } } ?> \ No newline at end of file diff --git a/phpgwapi/inc/adodb/drivers/adodb-borland_ibase.inc.php b/phpgwapi/inc/adodb/drivers/adodb-borland_ibase.inc.php index 208d5e7d91..c130afaaa9 100644 --- a/phpgwapi/inc/adodb/drivers/adodb-borland_ibase.inc.php +++ b/phpgwapi/inc/adodb/drivers/adodb-borland_ibase.inc.php @@ -1,17 +1,20 @@ ADODB_ibase(); } + function BeginTrans() + { + if ($this->transOff) return true; + $this->transCnt += 1; + $this->autoCommit = false; + $this->_transactionID = ibase_trans($this->ibasetrans, $this->_connectionID); + return $this->_transactionID; + } + function ServerInfo() { $arr['dialect'] = $this->dialect; diff --git a/phpgwapi/inc/adodb/drivers/adodb-csv.inc.php b/phpgwapi/inc/adodb/drivers/adodb-csv.inc.php index 3a1ac86acd..db65a9e65a 100644 --- a/phpgwapi/inc/adodb/drivers/adodb-csv.inc.php +++ b/phpgwapi/inc/adodb/drivers/adodb-csv.inc.php @@ -1,6 +1,6 @@ ADODB_ibase(); diff --git a/phpgwapi/inc/adodb/drivers/adodb-ibase.inc.php b/phpgwapi/inc/adodb/drivers/adodb-ibase.inc.php index e9f5e83023..71078d8bcf 100644 --- a/phpgwapi/inc/adodb/drivers/adodb-ibase.inc.php +++ b/phpgwapi/inc/adodb/drivers/adodb-ibase.inc.php @@ -1,11 +1,11 @@ Execute("insert into table (id, col1,...) values ($id, $val1,...)"); */ +// security - hide paths +if (!defined('ADODB_DIR')) die(); class ADODB_ibase extends ADOConnection { var $databaseType = "ibase"; var $dataProvider = "ibase"; var $replaceQuote = "''"; // string to use to replace quotes - var $ibase_timefmt = '%Y-%m-%d'; // For hours,mins,secs change to '%Y-%m-%d %H:%M:%S'; + var $ibase_datefmt = '%Y-%m-%d'; // For hours,mins,secs change to '%Y-%m-%d %H:%M:%S'; var $fmtDate = "'Y-m-d'"; + var $ibase_timestampfmt = "%Y-%m-%d %H:%M:%S"; + var $ibase_timefmt = "%H:%M:%S"; var $fmtTimeStamp = "'Y-m-d, H:i:s'"; var $concat_operator='||'; var $_transactionID; @@ -42,7 +46,7 @@ class ADODB_ibase extends ADOConnection { var $_bindInputArray = true; var $buffers = 0; var $dialect = 1; - var $sysDate = "cast('TODAY' as date)"; + var $sysDate = "cast('TODAY' as timestamp)"; var $sysTimeStamp = "cast('NOW' as timestamp)"; var $ansiOuter = true; var $hasAffectedRows = false; @@ -109,6 +113,23 @@ class ADODB_ibase extends ADOConnection { return $ret; } + // there are some compat problems with ADODB_COUNTRECS=false and $this->_logsql currently. + // it appears that ibase extension cannot support multiple concurrent queryid's + function &_Execute($sql,$inputarr=false) + { + global $ADODB_COUNTRECS; + + if ($this->_logsql) { + $savecrecs = $ADODB_COUNTRECS; + $ADODB_COUNTRECS = true; // force countrecs + $ret =& ADOConnection::_Execute($sql,$inputarr); + $ADODB_COUNTRECS = $savecrecs; + } else { + $ret =& ADOConnection::_Execute($sql,$inputarr); + } + return $ret; + } + function RollbackTrans() { if ($this->transOff) return true; @@ -237,28 +258,14 @@ class ADODB_ibase extends ADOConnection { } // returns true or false - function _connect($argHostname, $argUsername, $argPassword, $argDatabasename) + function _connect($argHostname, $argUsername, $argPassword, $argDatabasename,$persist=false) { - if (!function_exists('ibase_pconnect')) return false; + if (!function_exists('ibase_pconnect')) return null; if ($argDatabasename) $argHostname .= ':'.$argDatabasename; - $this->_connectionID = ibase_connect($argHostname,$argUsername,$argPassword,$this->charSet,$this->buffers,$this->dialect); - if ($this->dialect != 1) { // http://www.ibphoenix.com/ibp_60_del_id_ds.html - $this->replaceQuote = "''"; - } - if ($this->_connectionID === false) { - $this->_handleerror(); - return false; - } + $fn = ($persist) ? 'ibase_pconnect':'ibase_connect'; + $this->_connectionID = $fn($argHostname,$argUsername,$argPassword, + $this->charSet,$this->buffers,$this->dialect); - ibase_timefmt($this->ibase_timefmt); - return true; - } - // returns true or false - function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename) - { - if (!function_exists('ibase_pconnect')) return false; - if ($argDatabasename) $argHostname .= ':'.$argDatabasename; - $this->_connectionID = ibase_pconnect($argHostname,$argUsername,$argPassword,$this->charSet,$this->buffers,$this->dialect); if ($this->dialect != 1) { // http://www.ibphoenix.com/ibp_60_del_id_ds.html $this->replaceQuote = "''"; } @@ -267,8 +274,29 @@ class ADODB_ibase extends ADOConnection { return false; } - ibase_timefmt($this->ibase_timefmt); + // PHP5 change. + if (function_exists('ibase_timefmt')) { + ibase_timefmt($this->ibase_datefmt,IBASE_DATE ); + if ($this->dialect == 1) ibase_timefmt($this->ibase_datefmt,IBASE_TIMESTAMP ); + else ibase_timefmt($this->ibase_timestampfmt,IBASE_TIMESTAMP ); + ibase_timefmt($this->ibase_timefmt,IBASE_TIME ); + } else { + ini_set("ibase.timestampformat", $this->base_timestampfmt); + ini_set("ibase.dateformat", $this->ibase_datefmt); + ini_set("ibase.timeformat", $this->ibase_timefmt); + } + //you can use + /* + ini_set("ibase.timestampformat", $this->ibase_timestampfmt); + ini_set("ibase.dateformat", $this->ibase_datefmt); + ini_set("ibase.timeformat", $this->ibase_timefmt); + */ return true; + } + // returns true or false + function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename) + { + return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename,true); } function Prepare($sql) @@ -293,7 +321,6 @@ class ADODB_ibase extends ADOConnection { if (is_array($sql)) { $fn = 'ibase_execute'; $sql = $sql[1]; - if (is_array($iarr)) { if (ADODB_PHPVER >= 0x4050) { // actually 4.0.4 if ( !isset($iarr[0]) ) $iarr[0] = ''; // PHP5 compat hack @@ -318,7 +345,7 @@ class ADODB_ibase extends ADOConnection { if (is_array($iarr)) { if (ADODB_PHPVER >= 0x4050) { // actually 4.0.4 - if ( !isset($iarr[0]) ) $iarr[0] = ''; // PHP5 compat hack + if (sizeof($iarr) == 0) $iarr[0] = ''; // PHP5 compat hack $fnarr =& array_merge( array($conn,$sql) , $iarr); $ret = call_user_func_array($fn,$fnarr); } else { @@ -350,7 +377,7 @@ class ADODB_ibase extends ADOConnection { } //OPN STUFF start - function _ConvertFieldType(&$fld, $ftype, $flen, $fscale, $fsubtype, $fprecision, $isInterbase6) + function _ConvertFieldType(&$fld, $ftype, $flen, $fscale, $fsubtype, $fprecision, $dialect3) { $fscale = abs($fscale); $fld->max_length = $flen; @@ -358,7 +385,7 @@ class ADODB_ibase extends ADOConnection { switch($ftype){ case 7: case 8: - if ($isInterbase6) { + if ($dialect3) { switch($fsubtype){ case 0: $fld->type = ($ftype == 7 ? 'smallint' : 'integer'); @@ -385,7 +412,7 @@ class ADODB_ibase extends ADOConnection { } break; case 16: - if ($isInterbase6) { + if ($dialect3) { switch($fsubtype){ case 0: $fld->type = 'decimal'; @@ -421,16 +448,18 @@ class ADODB_ibase extends ADOConnection { } break; case 35: - if ($isInterbase6) { + if ($dialect3) { $fld->type = 'timestamp'; } else { $fld->type = 'date'; } break; case 12: - case 13: $fld->type = 'date'; break; + case 13: + $fld->type = 'time'; + break; case 37: $fld->type = 'varchar'; break; @@ -461,13 +490,13 @@ class ADODB_ibase extends ADOConnection { $retarr = array(); //OPN STUFF start - $isInterbase6 = ($this->dialect==3 ? true : false); + $dialect3 = ($this->dialect==3 ? true : false); //OPN STUFF end while (!$rs->EOF) { //print_r($rs->fields); $fld = new ADOFieldObject(); $fld->name = trim($rs->fields[0]); //OPN STUFF start - $this->_ConvertFieldType($fld, $rs->fields[7], $rs->fields[3], $rs->fields[4], $rs->fields[5], $rs->fields[6], $isInterbase6); + $this->_ConvertFieldType($fld, $rs->fields[7], $rs->fields[3], $rs->fields[4], $rs->fields[5], $rs->fields[6], $dialect3); if (isset($rs->fields[1]) && $rs->fields[1]) { $fld->not_null = true; } @@ -666,7 +695,7 @@ class ADODB_ibase extends ADOConnection { Class Name: Recordset --------------------------------------------------------------------------------------*/ -class ADORecordset_ibase extends ADORecordSet +class ADORecordset_ibase extends ADORecordSet { var $databaseType = "ibase"; @@ -678,7 +707,7 @@ class ADORecordset_ibase extends ADORecordSet global $ADODB_FETCH_MODE; $this->fetchMode = ($mode === false) ? $ADODB_FETCH_MODE : $mode; - return $this->ADORecordSet($id); + $this->ADORecordSet($id); } /* Returns: an object containing field information. @@ -690,31 +719,47 @@ class ADORecordset_ibase extends ADORecordSet { $fld = new ADOFieldObject; $ibf = ibase_field_info($this->_queryID,$fieldOffset); - $fld->name = strtolower($ibf['alias']); - if (empty($fld->name)) $fld->name = strtolower($ibf['name']); + switch (ADODB_ASSOC_CASE) { + case 2: // the default + $fld->name = ($ibf['alias']); + if (empty($fld->name)) $fld->name = ($ibf['name']); + break; + case 0: + $fld->name = strtoupper($ibf['alias']); + if (empty($fld->name)) $fld->name = strtoupper($ibf['name']); + break; + case 1: + $fld->name = strtolower($ibf['alias']); + if (empty($fld->name)) $fld->name = strtolower($ibf['name']); + break; + } + $fld->type = $ibf['type']; $fld->max_length = $ibf['length']; + + /* This needs to be populated from the metadata */ + $fld->not_null = false; + $fld->has_default = false; + $fld->default_value = 'null'; return $fld; } function _initrs() { - $this->_numOfRows = -1; - $this->_numOfFields = @ibase_num_fields($this->_queryID); - - // cache types for blob decode check - for ($i=0, $max = $this->_numOfFields; $i < $max; $i++) { - $f1 = $this->FetchField($i); - $this->_cacheType[] = $f1->type; - } + $this->_numOfRows = -1; + $this->_numOfFields = @ibase_num_fields($this->_queryID); + + // cache types for blob decode check + for ($i=0, $max = $this->_numOfFields; $i < $max; $i++) { + $f1 = $this->FetchField($i); + $this->_cacheType[] = $f1->type; + } } function _seek($row) { return false; } - - function _fetch() { @@ -768,7 +813,7 @@ class ADORecordset_ibase extends ADORecordSet } } - return $this->fields[$this->bind[strtoupper($colname)]]; + return $this->fields[$this->bind[strtoupper($colname)]]; } @@ -799,7 +844,7 @@ class ADORecordset_ibase extends ADORecordSet case 'TIMESTAMP': case 'DATE': return 'D'; - + case 'TIME': return 'T'; //case 'T': return 'T'; //case 'L': return 'L'; diff --git a/phpgwapi/inc/adodb/drivers/adodb-informix.inc.php b/phpgwapi/inc/adodb/drivers/adodb-informix.inc.php index 228a406c29..f8b0bec8f9 100644 --- a/phpgwapi/inc/adodb/drivers/adodb-informix.inc.php +++ b/phpgwapi/inc/adodb/drivers/adodb-informix.inc.php @@ -1,6 +1,6 @@ SetFetchMode($savem); $ADODB_FETCH_MODE = $save; if ($rs === false) return false; + $rspkey = $this->Execute(sprintf($this->metaPrimaryKeySQL,$table)); //Added to get primary key colno items $retarr = array(); while (!$rs->EOF) { //print_r($rs->fields); $fld = new ADOFieldObject(); $fld->name = $rs->fields[0]; $fld->type = $rs->fields[1]; + $fld->primary_key=$rspkey->fields && array_search($rs->fields[4],$rspkey->fields); //Added to set primary key flag $fld->max_length = $rs->fields[2]; if (trim($rs->fields[3]) != "AAAAAA 0") { $fld->has_default = 1; @@ -194,7 +207,7 @@ class ADODB_informix72 extends ADOConnection { // returns true or false function _connect($argHostname, $argUsername, $argPassword, $argDatabasename) { - if (!function_exists('ifx_connect')) return false; + if (!function_exists('ifx_connect')) return null; $dbs = $argDatabasename . "@" . $argHostname; if ($argHostname) putenv("INFORMIXSERVER=$argHostname"); @@ -208,7 +221,7 @@ class ADODB_informix72 extends ADOConnection { // returns true or false function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename) { - if (!function_exists('ifx_connect')) return false; + if (!function_exists('ifx_connect')) return null; $dbs = $argDatabasename . "@" . $argHostname; putenv("INFORMIXSERVER=".trim($argHostname)); diff --git a/phpgwapi/inc/adodb/drivers/adodb-ldap.inc.php b/phpgwapi/inc/adodb/drivers/adodb-ldap.inc.php index 8092899072..180335a977 100644 --- a/phpgwapi/inc/adodb/drivers/adodb-ldap.inc.php +++ b/phpgwapi/inc/adodb/drivers/adodb-ldap.inc.php @@ -1,6 +1,6 @@ _connectionID = mssql_connect($argHostname,$argUsername,$argPassword); if ($this->_connectionID === false) return false; if ($argDatabasename) return $this->SelectDB($argDatabasename); @@ -446,7 +449,7 @@ order by constraint_name, referenced_table_name, keyno"; // returns true or false function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename) { - if (!function_exists('mssql_pconnect')) return false; + if (!function_exists('mssql_pconnect')) return null; $this->_connectionID = mssql_pconnect($argHostname,$argUsername,$argPassword); if ($this->_connectionID === false) return false; @@ -771,7 +774,7 @@ class ADORecordset_mssql extends ADORecordSet { $this->fields = @mssql_fetch_assoc($this->_queryID); else { $this->fields = @mssql_fetch_array($this->_queryID); - if (is_array($$this->fields)) { + if (@is_array($$this->fields)) { $fassoc = array(); foreach($$this->fields as $k => $v) { if (is_integer($k)) continue; diff --git a/phpgwapi/inc/adodb/drivers/adodb-mssqlpo.inc.php b/phpgwapi/inc/adodb/drivers/adodb-mssqlpo.inc.php index c64119f141..a9f03e974a 100644 --- a/phpgwapi/inc/adodb/drivers/adodb-mssqlpo.inc.php +++ b/phpgwapi/inc/adodb/drivers/adodb-mssqlpo.inc.php @@ -1,6 +1,6 @@ metaTablesSQL; + if ($showSchema && is_string($showSchema)) { + $this->metaTablesSQL .= " from $showSchema"; + } + if ($mask) { - $save = $this->metaTablesSQL; $mask = $this->qstr($mask); $this->metaTablesSQL .= " like $mask"; } $ret =& ADOConnection::MetaTables($ttype,$showSchema); - if ($mask) { - $this->metaTablesSQL = $save; - } + $this->metaTablesSQL = $save; return $ret; } @@ -148,13 +153,16 @@ class ADODB_mysql extends ADOConnection { function GetOne($sql,$inputarr=false) { - $rs =& $this->SelectLimit($sql,1,-1,$inputarr); - if ($rs) { - $rs->Close(); - if ($rs->EOF) return false; - return reset($rs->fields); + if (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; } @@ -431,6 +439,8 @@ class ADODB_mysql extends ADOConnection { 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); @@ -532,7 +542,6 @@ class ADORecordSet_mysql extends ADORecordSet{ function &FetchField($fieldOffset = -1) { - if ($fieldOffset != -1) { $o = @mysql_fetch_field($this->_queryID, $fieldOffset); $f = @mysql_field_flags($this->_queryID,$fieldOffset); diff --git a/phpgwapi/inc/adodb/drivers/adodb-mysqli.inc.php b/phpgwapi/inc/adodb/drivers/adodb-mysqli.inc.php index 19ef810728..2ee13a4e6c 100644 --- a/phpgwapi/inc/adodb/drivers/adodb-mysqli.inc.php +++ b/phpgwapi/inc/adodb/drivers/adodb-mysqli.inc.php @@ -1,6 +1,6 @@ qstr(HTTP_GET_VARS['name'],get_magic_quotes_gpc()); function qstr($s, $magic_quotes = false) { - if (!$magic_quotes) { - if (ADODB_PHPVER >= 0x5000) { - // $this->_connectionID = $this->mysqli_resolve_link($this->_connectionID); - return "'" . mysqli_real_escape_string($this->_connectionID, $s) . "'"; - } - else - { - trigger_error("phpver < 5 not implemented", E_USER_ERROR); - } + 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); - } + if ($this->replaceQuote[0] == '\\') + $s = adodb_str_replace(array('\\',"\0"),array('\\\\',"\\\0"),$s); return "'".str_replace("'",$this->replaceQuote,$s)."'"; } // undo magic quotes for " @@ -632,10 +628,11 @@ class ADORecordSet_mysqli extends ADORecordSet{ function ADORecordSet_mysqli($queryID, $mode = false) { if ($mode === false) - { + { global $ADODB_FETCH_MODE; $mode = $ADODB_FETCH_MODE; - } + } + switch ($mode) { case ADODB_FETCH_NUM: @@ -647,31 +644,26 @@ class ADORecordSet_mysqli extends ADORecordSet{ case ADODB_FETCH_DEFAULT: case ADODB_FETCH_BOTH: default: - $this->fetchMode = MYSQLI_ASSOC; + $this->fetchMode = MYSQLI_BOTH; break; } + $this->ADORecordSet($queryID); } function _initrs() { - // mysqli_num_rows only return correct number, depens - // on the use of mysql_store_result and mysql_use_result - if (!$this->Connection->executeOnly) { - $this->_numOfRows = @mysqli_num_rows($this->_queryID); - $this->_numOfFields = @mysqli_num_fields($this->_queryID); - } - else { - $this->_numOfRows = 0; - $this->_numOfFields = 0; - } + global $ADODB_COUNTRECS; + + $this->_numOfRows = $ADODB_COUNTRECS ? @mysqli_num_rows($this->_queryID) : -1; + $this->_numOfFields = @mysqli_num_fields($this->_queryID); } function &FetchField($fieldOffset = -1) { $fieldnr = $fieldOffset; if ($fieldOffset != -1) { - $fieldOffset = mysqi_field_seek($this->_queryID, $fieldnr); + $fieldOffset = mysqli_field_seek($this->_queryID, $fieldnr); } $o = mysqli_fetch_field($this->_queryID); return $o; @@ -719,43 +711,25 @@ class ADORecordSet_mysqli extends ADORecordSet{ // Other functions return no or the wrong results. function MoveNext() { - if ($this->EOF) - return false; - $this->_currentRow++; - switch($this->fetchMode) - { - case MYSQLI_NUM: - $this->fields = mysqli_fetch_array($this->_queryID); - break; - case MYSQLI_ASSOC: - case MYSQLI_BOTH: - $this->fields = mysqli_fetch_assoc($this->_queryID); - break; - default: - } - if (is_array($this->fields)) - return true; - $this->EOF = true; - return false; + 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() { - // mysqli_fetch_array($this->_queryID, MYSQLI_NUM) does not - // work (22-10-2003). But mysqli_fetch_array($this->_queryID) gives - // int resulttype should default to MYSQLI_BOTH,but give MYSQLI_NUM. - - // $this->fields = mysqli_fetch_fields($this->_queryID); - // $this->fields = mysqli_fetch_array($this->_queryID); //, $this->fetchMode); - - $this->fields = mysqli_fetch_assoc($this->_queryID); // $this->fetchMode); - return is_array($this->fields); + $this->fields = mysqli_fetch_array($this->_queryID,$this->fetchMode); + return is_array($this->fields); } function _close() { - mysqli_free_result($this->_queryID); - $this->_queryID = false; + mysqli_free_result($this->_queryID); + $this->_queryID = false; } function MetaType($t, $len = -1, $fieldobj = false) diff --git a/phpgwapi/inc/adodb/drivers/adodb-mysqlt.inc.php b/phpgwapi/inc/adodb/drivers/adodb-mysqlt.inc.php index 6b8b39529b..1b102389a4 100644 --- a/phpgwapi/inc/adodb/drivers/adodb-mysqlt.inc.php +++ b/phpgwapi/inc/adodb/drivers/adodb-mysqlt.inc.php @@ -1,7 +1,7 @@ 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 @@ -35,6 +38,20 @@ 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'; @@ -67,6 +84,7 @@ class ADODB_oci8 extends ADOConnection { 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 @@ -156,7 +174,7 @@ NATSOFT.DOMAIN = */ function _connect($argHostname, $argUsername, $argPassword, $argDatabasename,$mode=0) { - if (!function_exists('OCIPLogon')) return false; + if (!function_exists('OCIPLogon')) return null; $this->_errorMsg = false; @@ -680,8 +698,9 @@ NATSOFT.DOMAIN = 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) + 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) { @@ -689,15 +708,39 @@ NATSOFT.DOMAIN = } if ($name == false) { - if ($type !== false) $rez = OCIBindByName($stmt[1],":".$name,$var,$size,$type); + 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 ($type == OCI_B_BLOB){ + } else if (oci_lob_desc($type)) { + if ($this->debug) { + ADOConnection::outp("Bind: name = $name"); + } //we have to create a new Descriptor here - $_blob = OCINewDescriptor($this->_connectionID, OCI_D_LOB); - $rez = OCIBindByName($stmt[1], ":".$name, &$_blob, -1, OCI_B_BLOB); - $rez = $_blob; + $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("Bind: descriptor has been allocated, var binded"); + } + + // if type is input then write data to lob now + if ($isOutput == false) { + $var = $this -> BlobEncode($var); + $tmp -> WriteTemporary($var); + if ($this->debug) { + ADOConnection::outp("Bind: LOB has been written to temp"); + } + } else { + $this -> _refLOBs[$numlob]['VAR'] = &$var; + } + $rez = $tmp; } else { + if ($this->debug) + ADOConnection::outp("Bind: 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 } @@ -733,7 +776,7 @@ NATSOFT.DOMAIN = $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); + return $this->Bind($stmt,$var,$maxLen,$type,$name,$isOutput); } /* @@ -807,6 +850,22 @@ NATSOFT.DOMAIN = $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("OUT LOB: LOB has been loaded.
    "); + } + //$_GLOBALS[$this -> _refLOBs[$key]['VAR']] = $tmp; + $this -> _refLOBs[$key]['VAR'] = $tmp; + } + $this -> _refLOBs[$key]['LOB'] -> free(); + unset($this -> _refLOBs[$key]); + } + } switch (@OCIStatementType($stmt)) { case "SELECT": @@ -840,6 +899,12 @@ NATSOFT.DOMAIN = function _close() { if (!$this->autoCommit) OCIRollback($this->_connectionID); + if (count($this -> _refLOBs) > 0) { + foreach ($this -> _refLOBs as $key => $value) { + $this -> _refLOBs[$key] -> free(); + unset($this -> _refLOBs[$key]); + } + } OCILogoff($this->_connectionID); $this->_stmt = false; $this->_connectionID = false; @@ -944,7 +1009,6 @@ SELECT /*+ RULE */ distinct b.column_name { $nofixquotes=false; - if (is_array($s)) adodb_backtrace(); if ($this->noNullStrings && strlen($s)==0)$s = ' '; if (!$magic_quotes) { if ($this->replaceQuote[0] == '\\'){ @@ -956,12 +1020,9 @@ SELECT /*+ RULE */ distinct b.column_name // undo magic quotes for " $s = str_replace('\\"','"',$s); - if ($this->replaceQuote == "\\'") // ' already quoted, no need to change anything - return "'$s'"; - else {// change \' to '' for sybase/mssql - $s = str_replace('\\\\','\\',$s); - return "'".str_replace("\\'",$this->replaceQuote,$s)."'"; - } + $s = str_replace('\\\\','\\',$s); + return "'".str_replace("\\'",$this->replaceQuote,$s)."'"; + } } diff --git a/phpgwapi/inc/adodb/drivers/adodb-oci805.inc.php b/phpgwapi/inc/adodb/drivers/adodb-oci805.inc.php index e4b9a8402b..d7991d12ab 100644 --- a/phpgwapi/inc/adodb/drivers/adodb-oci805.inc.php +++ b/phpgwapi/inc/adodb/drivers/adodb-oci805.inc.php @@ -1,6 +1,6 @@ debug && $argDatabasename && $this->databaseType != 'vfp') { ADOConnection::outp("For odbc Connect(), $argDatabasename is not used. Place dsn in 1st parameter."); } - $php_errormsg = ''; + 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 = $php_errormsg; + $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : ''; if (isset($this->connectStmt)) $this->Execute($this->connectStmt); //if ($this->_connectionID) odbc_autocommit($this->_connectionID,true); @@ -177,9 +180,10 @@ class ADODB_odbc extends ADOConnection { { global $php_errormsg; - if (!function_exists('odbc_connect')) return false; + if (!function_exists('odbc_connect')) return null; - $php_errormsg = ''; + 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."); } @@ -187,7 +191,7 @@ class ADODB_odbc extends ADOConnection { if ($this->curmode === false) $this->_connectionID = odbc_connect($argDSN,$argUsername,$argPassword); else $this->_connectionID = odbc_pconnect($argDSN,$argUsername,$argPassword,$this->curmode); - $this->_errorMsg = $php_errormsg; + $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : ''; if ($this->_connectionID && $this->autoRollback) @odbc_rollback($this->_connectionID); if (isset($this->connectStmt)) $this->Execute($this->connectStmt); @@ -466,7 +470,7 @@ class ADODB_odbc extends ADOConnection { function _query($sql,$inputarr=false) { GLOBAL $php_errormsg; - $php_errormsg = ''; + if (isset($php_errormsg)) $php_errormsg = ''; $this->_error = ''; if ($inputarr) { @@ -476,7 +480,7 @@ class ADODB_odbc extends ADOConnection { $stmtid = odbc_prepare($this->_connectionID,$sql); if ($stmtid == false) { - $this->_errorMsg = $php_errormsg; + $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : ''; return false; } } @@ -518,13 +522,13 @@ class ADODB_odbc extends ADOConnection { $this->_errorMsg = ''; $this->_errorCode = 0; } else - $this->_errorMsg = $php_errormsg; + $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : ''; } else { if ($this->_haserrorfunctions) { $this->_errorMsg = odbc_errormsg(); $this->_errorCode = odbc_error(); } else - $this->_errorMsg = $php_errormsg; + $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : ''; } return $stmtid; } @@ -707,4 +711,4 @@ class ADORecordSet_odbc extends ADORecordSet { } -?> +?> \ No newline at end of file diff --git a/phpgwapi/inc/adodb/drivers/adodb-odbc_mssql.inc.php b/phpgwapi/inc/adodb/drivers/adodb-odbc_mssql.inc.php index 3e62bd31fc..38c7eb70e9 100644 --- a/phpgwapi/inc/adodb/drivers/adodb-odbc_mssql.inc.php +++ b/phpgwapi/inc/adodb/drivers/adodb-odbc_mssql.inc.php @@ -1,17 +1,20 @@ +// security - hide paths +if (!defined('ADODB_DIR')) die(); + define("_ADODB_ODBTP_LAYER", 2 ); class ADODB_odbtp extends ADOConnection{ diff --git a/phpgwapi/inc/adodb/drivers/adodb-odbtp_unicode.inc.php b/phpgwapi/inc/adodb/drivers/adodb-odbtp_unicode.inc.php index 3d0512e738..bee94d2184 100644 --- a/phpgwapi/inc/adodb/drivers/adodb-odbtp_unicode.inc.php +++ b/phpgwapi/inc/adodb/drivers/adodb-odbtp_unicode.inc.php @@ -1,15 +1,18 @@ +// security - hide paths +if (!defined('ADODB_DIR')) die(); + /* Because the ODBTP server sends and reads UNICODE text data using UTF-8 encoding, the following HTML meta tag must be included within the HTML diff --git a/phpgwapi/inc/adodb/drivers/adodb-oracle.inc.php b/phpgwapi/inc/adodb/drivers/adodb-oracle.inc.php index 78ec801343..765c50b319 100644 --- a/phpgwapi/inc/adodb/drivers/adodb-oracle.inc.php +++ b/phpgwapi/inc/adodb/drivers/adodb-oracle.inc.php @@ -1,18 +1,20 @@ fmtTimeStamp,$ts).",'RRRR-MM-DD, HH:MI:SS AM')"; } @@ -71,17 +74,22 @@ class ADODB_oracle extends ADOConnection { /* there seems to be a bug in the oracle extension -- always returns ORA-00000 - no error */ function ErrorMsg() - { - $this->_errorMsg = @ora_error($this->_curs); - if (!$this->_errorMsg) $this->_errorMsg = @ora_error($this->_connectionID); + { + 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() { - $err = @ora_errorcode($this->_curs); - if (!$err) return @ora_errorcode($this->_connectionID); + 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; } @@ -89,6 +97,12 @@ class ADODB_oracle extends ADOConnection { // returns true or false function _connect($argHostname, $argUsername, $argPassword, $argDatabasename, $mode=0) { + if (!function_exists('ora_plogon')) return null; + + // 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"); @@ -143,13 +157,21 @@ class ADODB_oracle extends ADOConnection { // returns query ID if successful, otherwise false function _query($sql,$inputarr=false) { + // 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; - + // 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); + // @ora_close($curs); return false; } diff --git a/phpgwapi/inc/adodb/drivers/adodb-pdo.inc.php b/phpgwapi/inc/adodb/drivers/adodb-pdo.inc.php new file mode 100644 index 0000000000..c8f411c2c4 --- /dev/null +++ b/phpgwapi/inc/adodb/drivers/adodb-pdo.inc.php @@ -0,0 +1,319 @@ +_connectionID = new PDO($argDSN, $argUsername, $argPassword); + 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); + + //$this->_connectionID->setAttribute(PDO_ATTR_AUTOCOMMIT,true); + + return true; + } + return false; + } + + // returns true or false + function _pconnect($argDSN, $argUsername, $argPassword, $argDatabasename) + { + return $this->_connect($argDSN, $argUsername, $argPassword, $argDatabasename, true); + } + + function ErrorMsg() + { + if ($this->_stmt) $arr = $this->_stmt->errorInfo(); + else $arr = $this->_connectionID->errorInfo(); + + if ($arr) { + if ($arr[0]) return $arr[2]; + else return ''; + } else return '-1'; + } + + 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 ErrorNo() + { + + if ($this->_stmt) return $this->_stmt->errorCode(); + else return $this->_connectionID->errorInfo(); + } + + 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->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->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) { + if ($inputarr) $stmt->execute($inputarr); + else $stmt->execute(); + } + $this->_stmt = $stmt; + return $stmt; + } + + // 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(); + print_r($arr); + if ($arr) { + if ($arr[0]) return $arr[2]; + else return ''; + } else return '-1'; + } + + 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; + } + switch($mode) { + default: + case ADODB_FETCH_BOTH: $mode = PDO_FETCH_BOTH; break; + case ADODB_FETCH_NUM: $mode = PDO_FETCH_NUM; break; + case ADODB_FETCH_ASSOC: $mode = PDO_FETCH_ASSOC; break; + } + $this->fetchMode = $mode; + + $this->_queryID = $id; + $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; + } + + 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 + } + $this->_numOfFields = sizeof($this->fields); + } 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 =0; + } + + function _seek($row) + { + return false; + } + + function _fetch() + { + $this->fields = $this->_queryID->fetch($this->fetchMode); + return !empty($this->fields); + } + + function _close() + { + $this->_queryID = false; + } + +} + +?> \ No newline at end of file diff --git a/phpgwapi/inc/adodb/drivers/adodb-postgres.inc.php b/phpgwapi/inc/adodb/drivers/adodb-postgres.inc.php index 40e733d160..7dbe34b8e2 100644 --- a/phpgwapi/inc/adodb/drivers/adodb-postgres.inc.php +++ b/phpgwapi/inc/adodb/drivers/adodb-postgres.inc.php @@ -1,6 +1,6 @@ EOF) { $num = $rsdef->fields['num']; $s = $rsdef->fields['def']; - if (substr($s, 0, 1) == "'") { /* quoted strings hack... for now... fixme */ + 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); } @@ -495,7 +501,7 @@ select viewname,'V' from pg_views where viewname like $mask"; $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" @@ -503,18 +509,18 @@ 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\' and c.relnamespace=c2.relnamespace and c.relnamespace=n.oid and n.nspname=\'%s\' AND i.indisprimary=false'; +WHERE (c2.relname=\'%s\' or c2.relname=lower(\'%s\')) and c.relnamespace=c2.relnamespace and c.relnamespace=n.oid and n.nspname=\'%s\' AND i.indisprimary=false'; } 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\''; +WHERE c2.relname=\'%s\' or c2.relname=lower(\'%s\')'; } if ($primary == FALSE) { - $sql .= ' AND i.indisprimary=false;'; + $sql .= ' AND i.indisprimary=false;'; } $save = $ADODB_FETCH_MODE; @@ -523,23 +529,20 @@ WHERE c2.relname=\'%s\''; $savem = $this->SetFetchMode(FALSE); } - $rs = $this->Execute(sprintf($sql,$table,$schema)); - + $rs = $this->Execute(sprintf($sql,$table,$table,$schema)); if (isset($savem)) { $this->SetFetchMode($savem); } $ADODB_FETCH_MODE = $save; - + if (!is_object($rs)) { - return FALSE; + return FALSE; } - - $col_names = $this->MetaColumnNames($table); + + $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]; } @@ -549,7 +552,6 @@ WHERE c2.relname=\'%s\''; 'columns' => $columns ); } - return $indexes; } @@ -561,7 +563,7 @@ WHERE c2.relname=\'%s\''; function _connect($str,$user='',$pwd='',$db='',$ctype=0) { - if (!function_exists('pg_pconnect')) return false; + if (!function_exists('pg_pconnect')) return null; $this->_errorMsg = false; @@ -720,7 +722,10 @@ WHERE c2.relname=\'%s\''; function ErrorNo() { $e = $this->ErrorMsg(); - return strlen($e) ? $e : 0; + if (strlen($e)) { + return ADOConnection::MetaError($e); + } + return 0; } // returns true or false @@ -791,14 +796,15 @@ class ADORecordSet_postgres64 extends ADORecordSet{ function _initrs() { global $ADODB_COUNTRECS; - $this->_numOfRows = ($ADODB_COUNTRECS)? @pg_numrows($this->_queryID):-1; - $this->_numOfFields = @pg_numfields($this->_queryID); + $qid = $this->_queryID; + $this->_numOfRows = ($ADODB_COUNTRECS)? @pg_numrows($qid):-1; + $this->_numOfFields = @pg_numfields($qid); // cache types for blob decode check for ($i=0, $max = $this->_numOfFields; $i < $max; $i++) { - $f1 = $this->FetchField($i); - //print_r($f1); - if ($f1->type == 'bytea') $this->_blobArr[$i] = $f1->name; + if (pg_fieldtype($qid,$i) == 'bytea') { + $this->_blobArr[$i] = pg_fieldname($qid,$off); + } } } @@ -817,16 +823,14 @@ class ADORecordSet_postgres64 extends ADORecordSet{ return $this->fields[$this->bind[strtoupper($colname)]]; } - function &FetchField($fieldOffset = 0) + function &FetchField($off = 0) { - $off=$fieldOffset; // offsets begin at 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); - //print_r($o); - //print "off=$off name=$o->name type=$o->type len=$o->max_length
    "; return $o; } diff --git a/phpgwapi/inc/adodb/drivers/adodb-postgres7.inc.php b/phpgwapi/inc/adodb/drivers/adodb-postgres7.inc.php index b92fe267fb..dbab597e65 100644 --- a/phpgwapi/inc/adodb/drivers/adodb-postgres7.inc.php +++ b/phpgwapi/inc/adodb/drivers/adodb-postgres7.inc.php @@ -1,6 +1,6 @@ _connectionID = sqlite_open($argHostname); if ($this->_connectionID === false) return false; @@ -138,7 +141,7 @@ class ADODB_sqlite extends ADOConnection { // returns true or false function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename) { - if (!function_exists('sqlite_open')) return false; + if (!function_exists('sqlite_open')) return null; $this->_connectionID = sqlite_popen($argHostname); if ($this->_connectionID === false) return false; diff --git a/phpgwapi/inc/adodb/drivers/adodb-sqlitepo.inc.php b/phpgwapi/inc/adodb/drivers/adodb-sqlitepo.inc.php new file mode 100644 index 0000000000..396039d8fe --- /dev/null +++ b/phpgwapi/inc/adodb/drivers/adodb-sqlitepo.inc.php @@ -0,0 +1,62 @@ +ADODB_sqlite(); + } +} + +/*-------------------------------------------------------------------------------------- + Class Name: Recordset +--------------------------------------------------------------------------------------*/ + +class ADORecordset_sqlitepo extends ADORecordset_sqlite { + + var $databaseType = 'sqlitepo'; + + function ADORecordset_sqlitepo($queryID,$mode=false) + { + $this->ADORecordset_sqlite($queryID,$mode); + } + + // Modified to strip table names from returned fields + function _fetch($ignore_fields=false) + { + $this->fields = array(); + $fields = @sqlite_fetch_array($this->_queryID,$this->fetchMode); + if(is_array($fields)) + foreach($fields as $n => $v) + { + if(($p = strpos($n, ".")) !== false) + $n = substr($n, $p+1); + $this->fields[$n] = $v; + } + + return !empty($this->fields); + } +} +?> \ No newline at end of file diff --git a/phpgwapi/inc/adodb/drivers/adodb-sybase.inc.php b/phpgwapi/inc/adodb/drivers/adodb-sybase.inc.php index 549179b078..d4123e3b12 100644 --- a/phpgwapi/inc/adodb/drivers/adodb-sybase.inc.php +++ b/phpgwapi/inc/adodb/drivers/adodb-sybase.inc.php @@ -1,12 +1,12 @@ _connectionID = sybase_connect($argHostname,$argUsername,$argPassword); if ($this->_connectionID === false) return false; @@ -122,7 +125,7 @@ class ADODB_sybase extends ADOConnection { // returns true or false function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename) { - if (!function_exists('sybase_connect')) return false; + if (!function_exists('sybase_connect')) return null; $this->_connectionID = sybase_pconnect($argHostname,$argUsername,$argPassword); if ($this->_connectionID === false) return false; diff --git a/phpgwapi/inc/adodb/drivers/adodb-vfp.inc.php b/phpgwapi/inc/adodb/drivers/adodb-vfp.inc.php index 5f5c1523d0..3c7ee2931f 100644 --- a/phpgwapi/inc/adodb/drivers/adodb-vfp.inc.php +++ b/phpgwapi/inc/adodb/drivers/adodb-vfp.inc.php @@ -1,16 +1,19 @@ + +$ADODB_LANG_ARRAY = array ( + 'LANG' => 'pl', + DB_ERROR => 'niezidentyfikowany błąd', + DB_ERROR_ALREADY_EXISTS => 'już istnieją', + DB_ERROR_CANNOT_CREATE => 'nie można stworzyć', + DB_ERROR_CANNOT_DELETE => 'nie można usunąć', + DB_ERROR_CANNOT_DROP => 'nie można porzucić', + DB_ERROR_CONSTRAINT => 'pogwałcenie uprawnień', + DB_ERROR_DIVZERO => 'dzielenie przez zero', + DB_ERROR_INVALID => 'błędny', + DB_ERROR_INVALID_DATE => 'błędna godzina lub data', + DB_ERROR_INVALID_NUMBER => 'błędny numer', + DB_ERROR_MISMATCH => 'niedopasowanie', + DB_ERROR_NODBSELECTED => 'baza danych nie została wybrana', + DB_ERROR_NOSUCHFIELD => 'nie znaleziono pola', + DB_ERROR_NOSUCHTABLE => 'nie znaleziono tabeli', + DB_ERROR_NOT_CAPABLE => 'nie zdolny', + DB_ERROR_NOT_FOUND => 'nie znaleziono', + DB_ERROR_NOT_LOCKED => 'nie zakmnięty', + DB_ERROR_SYNTAX => 'błąd składni', + DB_ERROR_UNSUPPORTED => 'nie obsługuje', + DB_ERROR_VALUE_COUNT_ON_ROW => 'wartość liczona w szeregu', + DB_ERROR_INVALID_DSN => 'błędny DSN', + DB_ERROR_CONNECT_FAILED => 'połączenie nie zostało zrealizowane', + 0 => 'brak błędów', // DB_OK + DB_ERROR_NEED_MORE_DATA => 'niedostateczna ilość informacji', + DB_ERROR_EXTENSION_NOT_FOUND=> 'nie znaleziono rozszerzenia', + DB_ERROR_NOSUCHDB => 'nie znaleziono bazy', + DB_ERROR_ACCESS_VIOLATION => 'niedostateczne uprawnienia' +); +?> + \ No newline at end of file diff --git a/phpgwapi/inc/adodb/license.txt b/phpgwapi/inc/adodb/license.txt index 786fc32bfe..9821fcb764 100644 --- a/phpgwapi/inc/adodb/license.txt +++ b/phpgwapi/inc/adodb/license.txt @@ -2,12 +2,12 @@ ADOdb is dual licensed using BSD and LGPL. In plain English, you do not need to distribute your application in source code form, nor do you need to distribute ADOdb source code, provided you follow the rest of terms of the BSD license. -Commercial use of ADOdb is encouraged. Make money and multiply! +For more info about ADOdb, visit http://adodb.sourceforge.net/ BSD Style-License ================= -Copyright (c) 2000, 2001, 2002, 2003 John Lim +Copyright (c) 2000, 2001, 2002, 2003, 2004 John Lim All rights reserved. Redistribution and use in source and binary forms, with or without modification, diff --git a/phpgwapi/inc/adodb/pear/Auth/Container/ADOdb.php b/phpgwapi/inc/adodb/pear/Auth/Container/ADOdb.php new file mode 100644 index 0000000000..e4ab3eb711 --- /dev/null +++ b/phpgwapi/inc/adodb/pear/Auth/Container/ADOdb.php @@ -0,0 +1,436 @@ + +// | Richard Tango-Lowy | +// +----------------------------------------------------------------------+ +// +// $Id$ +// + +require_once 'Auth/Container.php'; +require_once 'adodb.inc.php'; +require_once 'adodb-pear.inc.php'; +require_once 'adodb-errorpear.inc.php'; + +/** + * Storage driver for fetching login data from a database using ADOdb-PHP. + * + * This storage driver can use all databases which are supported + * by the ADBdb DB abstraction layer to fetch login data. + * See http://php.weblogs.com/adodb for information on ADOdb. + * NOTE: The ADOdb directory MUST be in your PHP include_path! + * + * @author Richard Tango-Lowy + * @package Auth + * @version $Revision$ + */ +class Auth_Container_ADOdb extends Auth_Container +{ + + /** + * Additional options for the storage container + * @var array + */ + var $options = array(); + + /** + * DB object + * @var object + */ + var $db = null; + var $dsn = ''; + + /** + * User that is currently selected from the DB. + * @var string + */ + var $activeUser = ''; + + // {{{ Constructor + + /** + * Constructor of the container class + * + * Initate connection to the database via PEAR::ADOdb + * + * @param string Connection data or DB object + * @return object Returns an error object if something went wrong + */ + function Auth_Container_ADOdb($dsn) + { + $this->_setDefaults(); + + if (is_array($dsn)) { + $this->_parseOptions($dsn); + + if (empty($this->options['dsn'])) { + PEAR::raiseError('No connection parameters specified!'); + } + } else { + // Extract db_type from dsn string. + $this->options['dsn'] = $dsn; + $this->_parseDsn( $dsn ); + } + } + + // }}} + // {{{ _connect() + + /** + * Connect to database by using the given DSN string + * + * @access private + * @param string DSN string + * @return mixed Object on error, otherwise bool + */ + function _connect($dsn) + { + if (is_string($dsn) || is_array($dsn)) { + if(!$this->db) { + $this->db = &ADONewConnection($this->options['db_type']); + + if( $err = ADODB_Pear_error() ) { + return PEAR::raiseError($err); + } + } + + $dbconnected = $this->db->Connect( + $this->options['db_host'], + $this->options['db_user'], + $this->options['db_pass'], + $this->options['db_name'] ); + if( !$dbconnected ) { + PEAR::raiseError('Unable to connect to database' ); + } + + } else { + return PEAR::raiseError('The given dsn was not valid in file ' . __FILE__ . ' at line ' . __LINE__, + 41, + PEAR_ERROR_RETURN, + null, + null + ); + } + + if(!$this->db) { + return PEAR::raiseError(ADODB_Pear_error()); + } else { + return true; + } + } + + // }}} + // {{{ _prepare() + + /** + * Prepare database connection + * + * This function checks if we have already opened a connection to + * the database. If that's not the case, a new connection is opened. + * + * @access private + * @return mixed True or a DB error object. + */ + function _prepare() + { + if(!$this->db) { + $res = $this->_connect($this->options['dsn']); + } + return true; + } + + // }}} + // {{{ query() + + /** + * Prepare query to the database + * + * This function checks if we have already opened a connection to + * the database. If that's not the case, a new connection is opened. + * After that the query is passed to the database. + * + * @access public + * @param string Query string + * @return mixed a DB_result object or DB_OK on success, a DB + * or PEAR error on failure + */ + function query($query) + { + $err = $this->_prepare(); + if ($err !== true) { + return $err; + } + return $this->db->query($query); + } + + // }}} + // {{{ _setDefaults() + + /** + * Set some default options + * + * @access private + * @return void + */ + function _setDefaults() + { + $this->options['db_type'] = 'mysql'; + $this->options['table'] = 'auth'; + $this->options['usernamecol'] = 'username'; + $this->options['passwordcol'] = 'password'; + $this->options['dsn'] = ''; + $this->options['db_fields'] = ''; + $this->options['cryptType'] = 'md5'; + } + + // }}} + // {{{ _parseOptions() + + /** + * Parse options passed to the container class + * + * @access private + * @param array + */ + function _parseOptions($array) + { + foreach ($array as $key => $value) { + if (isset($this->options[$key])) { + $this->options[$key] = $value; + } + } + + /* Include additional fields if they exist */ + if(!empty($this->options['db_fields'])){ + if(is_array($this->options['db_fields'])){ + $this->options['db_fields'] = join($this->options['db_fields'], ', '); + } + $this->options['db_fields'] = ', '.$this->options['db_fields']; + } + } + + // }}} + // {{{ fetchData() + + /** + * Get user information from database + * + * This function uses the given username to fetch + * the corresponding login data from the database + * table. If an account that matches the passed username + * and password is found, the function returns true. + * Otherwise it returns false. + * + * @param string Username + * @param string Password + * @return mixed Error object or boolean + */ + function fetchData($username, $password) + { + // Prepare for a database query + $err = $this->_prepare(); + if ($err !== true) { + return PEAR::raiseError($err->getMessage(), $err->getCode()); + } + + // Find if db_fields contains a *, i so assume all col are selected + if(strstr($this->options['db_fields'], '*')){ + $sql_from = "*"; + } + else{ + $sql_from = $this->options['usernamecol'] . ", ".$this->options['passwordcol'].$this->options['db_fields']; + } + + $query = "SELECT ".$sql_from. + " FROM ".$this->options['table']. + " WHERE ".$this->options['usernamecol']." = " . $this->db->Quote($username); + + $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; + $rset = $this->db->Execute( $query ); + $res = $rset->fetchRow(); + + if (DB::isError($res)) { + return PEAR::raiseError($res->getMessage(), $res->getCode()); + } + if (!is_array($res)) { + $this->activeUser = ''; + return false; + } + if ($this->verifyPassword(trim($password, "\r\n"), + trim($res[$this->options['passwordcol']], "\r\n"), + $this->options['cryptType'])) { + // Store additional field values in the session + foreach ($res as $key => $value) { + if ($key == $this->options['passwordcol'] || + $key == $this->options['usernamecol']) { + continue; + } + // Use reference to the auth object if exists + // This is because the auth session variable can change so a static call to setAuthData does not make sence + if(is_object($this->_auth_obj)){ + $this->_auth_obj->setAuthData($key, $value); + } else { + Auth::setAuthData($key, $value); + } + } + + return true; + } + + $this->activeUser = $res[$this->options['usernamecol']]; + return false; + } + + // }}} + // {{{ listUsers() + + function listUsers() + { + $err = $this->_prepare(); + if ($err !== true) { + return PEAR::raiseError($err->getMessage(), $err->getCode()); + } + + $retVal = array(); + + // Find if db_fileds contains a *, i so assume all col are selected + if(strstr($this->options['db_fields'], '*')){ + $sql_from = "*"; + } + else{ + $sql_from = $this->options['usernamecol'] . ", ".$this->options['passwordcol'].$this->options['db_fields']; + } + + $query = sprintf("SELECT %s FROM %s", + $sql_from, + $this->options['table'] + ); + $res = $this->db->getAll($query, null, DB_FETCHMODE_ASSOC); + + if (DB::isError($res)) { + return PEAR::raiseError($res->getMessage(), $res->getCode()); + } else { + foreach ($res as $user) { + $user['username'] = $user[$this->options['usernamecol']]; + $retVal[] = $user; + } + } + return $retVal; + } + + // }}} + // {{{ addUser() + + /** + * Add user to the storage container + * + * @access public + * @param string Username + * @param string Password + * @param mixed Additional information that are stored in the DB + * + * @return mixed True on success, otherwise error object + */ + function addUser($username, $password, $additional = "") + { + if (function_exists($this->options['cryptType'])) { + $cryptFunction = $this->options['cryptType']; + } else { + $cryptFunction = 'md5'; + } + + $additional_key = ''; + $additional_value = ''; + + if (is_array($additional)) { + foreach ($additional as $key => $value) { + $additional_key .= ', ' . $key; + $additional_value .= ", '" . $value . "'"; + } + } + + $query = sprintf("INSERT INTO %s (%s, %s%s) VALUES ('%s', '%s'%s)", + $this->options['table'], + $this->options['usernamecol'], + $this->options['passwordcol'], + $additional_key, + $username, + $cryptFunction($password), + $additional_value + ); + + $res = $this->query($query); + + if (DB::isError($res)) { + return PEAR::raiseError($res->getMessage(), $res->getCode()); + } else { + return true; + } + } + + // }}} + // {{{ removeUser() + + /** + * Remove user from the storage container + * + * @access public + * @param string Username + * + * @return mixed True on success, otherwise error object + */ + function removeUser($username) + { + $query = sprintf("DELETE FROM %s WHERE %s = '%s'", + $this->options['table'], + $this->options['usernamecol'], + $username + ); + + $res = $this->query($query); + + if (DB::isError($res)) { + return PEAR::raiseError($res->getMessage(), $res->getCode()); + } else { + return true; + } + } + + // }}} + + function _parseDsn( $dsn ) + { + if( is_string( $dsn )) { + preg_match( '/^(\w*):\/\/(\w*)(:(\w*))?@(\w*)\/(\w*)$/', $dsn, $match ); + + $this->options['db_type'] = $match[1]; + $this->options['db_user'] = $match[2]; + $this->options['db_pass'] = $match[3]; + $this->options['db_host'] = $match[5]; + $this->options['db_name'] = $match[6]; + } + } +} + +function showDbg( $string ) { + print "

    $string

    "; +} +function dump( $var, $str, $vardump = false ) { + print "

    $str

    ";
    +	( !$vardump ) ? ( print_r( $var )) : ( var_dump( $var ));
    +	print "
    "; +} +?> diff --git a/phpgwapi/inc/adodb/pear/readme.Auth.txt b/phpgwapi/inc/adodb/pear/readme.Auth.txt new file mode 100644 index 0000000000..b6b0c15732 --- /dev/null +++ b/phpgwapi/inc/adodb/pear/readme.Auth.txt @@ -0,0 +1,20 @@ +From: Rich Tango-Lowy (richtl#arscognita.com) +Date: Sat, May 29, 2004 11:20 am + +OK, I hacked out an ADOdb container for PEAR-Auth. The error handling's +a bit of a mess, but all the methods work. + +Copy ADOdb.php to your pear/Auth/Container/ directory. + +Use the ADOdb container exactly as you would the DB +container, but specify 'ADOdb' instead of 'DB': + +$dsn = "mysql://myuser:mypass@localhost/authdb"; +$a = new Auth("ADOdb", $dsn, "loginFunction"); + + +------------------- + +John Lim adds: + +See http://pear.php.net/manual/en/package.authentication.php diff --git a/phpgwapi/inc/adodb/perf/perf-db2.inc.php b/phpgwapi/inc/adodb/perf/perf-db2.inc.php index dbda7f75d9..792fcd84af 100644 --- a/phpgwapi/inc/adodb/perf/perf-db2.inc.php +++ b/phpgwapi/inc/adodb/perf/perf-db2.inc.php @@ -1,17 +1,19 @@ array('DATAC', "select value from v\$parameter where name = 'shared_pool_size'", - 'shared_pool_size, which holds shared cursors, stored procedures and similar shared structs' ), + 'shared_pool_size, which holds shared sql, stored procedures, dict cache and similar shared structs' ), 'java pool size' => array('DATAJ', "select value from v\$parameter where name = 'java_pool_size'", 'java_pool_size' ), @@ -104,7 +107,7 @@ AND b.name = 'sorts (memory)'", "select round((1-bytes/sgasize)*100, 2) from (select sum(bytes) sgasize from sys.v_\$sgastat) s, sys.v_\$sgastat f where name = 'free memory' and pool = 'shared pool'", - 'Percentage of data cache actually in use - too low is bad, too high is worse'), + 'Percentage of data cache actually in use - should be over 85%'), 'shared pool utilization ratio' => array('RATIOU', 'select round((sga.bytes/p.value)*100,2) @@ -120,7 +123,7 @@ AND b.name = 'sorts (memory)'", 'Percentage of large_pool actually in use - too low is bad, too high is worse'), 'sort buffer size' => array('CACHE', "select value from v\$parameter where name='sort_area_size'", - 'sort_area_size (per query), uses memory in pga' ), + 'max in-mem sort_area_size (per query), uses memory in pga' ), 'pga usage at peak' => array('RATIOU', '=PGA','Mb utilization at peak transactions (requires Oracle 9i+)'), @@ -141,7 +144,12 @@ AND b.name = 'sorts (memory)'", 'cursor sharing' => array('CURSOR', "select value from v\$parameter where name = 'cursor_sharing'", 'Cursor reuse strategy. Recommended is FORCE (8i+) or SIMILAR (9i+). See cursor_sharing.'), - + /* + 'cursor reuse' => array('CURSOR', + "select count(*) from (select sql_text_wo_constants, count(*) + from t1 + group by sql_text_wo_constants +having count(*) > 100)",'These are sql statements that should be using bind variables'),*/ 'index cache cost' => array('COST', "select value from v\$parameter where name = 'optimizer_index_caching'", '% of indexed data blocks expected in the cache. diff --git a/phpgwapi/inc/adodb/perf/perf-postgres.inc.php b/phpgwapi/inc/adodb/perf/perf-postgres.inc.php index ad21adbc1c..b9392b12e8 100644 --- a/phpgwapi/inc/adodb/perf/perf-postgres.inc.php +++ b/phpgwapi/inc/adodb/perf/perf-postgres.inc.php @@ -1,18 +1,21 @@ EOF) { $ref = $rs->fields[0]; $key = $rs->fields[1]; - assert('$ref'); - assert('$key'); + //assert('$ref'); + //assert('$key'); $fn($ref, $key); } $rs->Close(); diff --git a/phpgwapi/inc/adodb/session/old/adodb-cryptsession.php b/phpgwapi/inc/adodb/session/old/adodb-cryptsession.php index 93fa88e820..3323e03b1a 100644 --- a/phpgwapi/inc/adodb/session/old/adodb-cryptsession.php +++ b/phpgwapi/inc/adodb/session/old/adodb-cryptsession.php @@ -1,6 +1,6 @@ Connect($pdo_connection_string,'','') || die("CONNECT FAILED"); +echo "Execute\n"; + + + +//$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; +$rs = $DB->Execute("select * from products where productid<3"); +echo "e=".$DB->ErrorNo() . " ".($DB->ErrorMsg())."\n"; + + +//print_r(get_class_methods($DB->_stmt)); + +if (!$rs) die("NO RS"); +echo "FETCH\n"; +$cnt = 0; +while (!$rs->EOF) { + print_r($rs->fields); + $rs->MoveNext(); + if ($cnt++ > 1000) break; +} + +echo "
    --------------------------------------------------------
    \n\n\n"; + +$stmt = $DB->PrepareStmt("select * from products"); +$rs = $stmt->Execute(); +echo "e=".$stmt->ErrorNo() . " ".($stmt->ErrorMsg())."\n"; +while ($arr = $rs->FetchRow()) { + print_r($arr); +} +die("DONE\n"); + +?> \ No newline at end of file diff --git a/phpgwapi/inc/adodb/tests/test-datadict.php b/phpgwapi/inc/adodb/tests/test-datadict.php index a25f2a62fb..3aa7d3bd6f 100644 --- a/phpgwapi/inc/adodb/tests/test-datadict.php +++ b/phpgwapi/inc/adodb/tests/test-datadict.php @@ -1,7 +1,7 @@ $dbType

    "; $db = NewADOConnection($dbType); $dict = NewDataDictionary($db); @@ -21,7 +21,7 @@ foreach(array('sybase','mysql','access','oci8','postgres','odbc_mssql','odbc','s if (!$dict) continue; $dict->debug = 1; - $opts = array('REPLACE','mysql' => 'TYPE=ISAM', 'oci8' => 'TABLESPACE USERS'); + $opts = array('REPLACE','mysql' => 'TYPE=INNODB', 'oci8' => 'TABLESPACE USERS'); /* $flds = array( array('id', 'I', diff --git a/phpgwapi/inc/adodb/tests/test-php5.php b/phpgwapi/inc/adodb/tests/test-php5.php index 5142e6942d..3a682fe602 100644 --- a/phpgwapi/inc/adodb/tests/test-php5.php +++ b/phpgwapi/inc/adodb/tests/test-php5.php @@ -1,6 +1,6 @@ PHP ".PHP_VERSION."\n"; try { -$dbt = 'oci8'; +$dbt = 'mysqli'; switch($dbt) { case 'oci8': @@ -30,6 +30,11 @@ case 'mysql': $db = NewADOConnection("mysql"); $db->Connect('localhost','root','','test'); break; + +case 'mysqli': + $db = NewADOConnection("mysqli"); + $db->Connect('localhost','root','','test'); + break; } $db->debug=1; diff --git a/phpgwapi/inc/adodb/tests/test-xmlschema.php b/phpgwapi/inc/adodb/tests/test-xmlschema.php index bfa70ca476..d3099fd3d9 100644 --- a/phpgwapi/inc/adodb/tests/test-xmlschema.php +++ b/phpgwapi/inc/adodb/tests/test-xmlschema.php @@ -1,6 +1,6 @@ \n"; // Finally, clean up after the XML parser // (PHP won't do this for you!) //$schema->Destroy(); + + +$db2 = ADONewConnection('mssql'); +$db2->Connect('localhost','sa','natsoft','northwind') || die("Fail 2"); + +$db2->Execute("drop table simple_table"); + +$schema = new adoSchema( $db2 ); +$sql = $schema->ParseSchema( "xmlschema-mssql.xml" ); + +print "Here's the SQL to do the build:\n

    ";
    +print_r( $sql );
    +print "
    \n"; + +$db2->debug=1; + +$db2->Execute($sql[0]); ?> \ No newline at end of file diff --git a/phpgwapi/inc/adodb/tests/test.php b/phpgwapi/inc/adodb/tests/test.php index b163089eb7..472eeb7c1c 100644 --- a/phpgwapi/inc/adodb/tests/test.php +++ b/phpgwapi/inc/adodb/tests/test.php @@ -1,12 +1,12 @@ Execute("drop table adodb_logsql"); if ((rand()%3) == 0) @$db->Execute("delete from adodb_logsql"); $db->debug=1; @@ -121,9 +122,8 @@ FROM `nuke_stories` `t1`, `nuke_authors` `t2`, `nuke_stories_cat` `t3`, `nuke_to if ($tt == 0) echo '
    $db->Time failed'; else echo "
    db->Time: ".date('d-m-Y H:i:s',$tt); echo '
    '; - - - + + echo "Date=",$db->UserDate('2002-04-07'),'
    '; print "date1 (1969-02-20) = ".$db->DBDate('1969-2-20'); print "
    date1 (1999-02-20) = ".$db->DBDate('1999-2-20'); print "
    date1.1 1999 = ".$db->DBDate("'1999'"); @@ -243,7 +243,7 @@ FROM `nuke_stories` `t1`, `nuke_authors` `t2`, `nuke_stories_cat` `t3`, `nuke_to if (1) { print "

    Testing MetaDatabases()

    "; print_r( $db->MetaDatabases()); - + print "

    Testing MetaTables() and MetaColumns()

    "; $a = $db->MetaTables(); if ($a===false) print "MetaTables not supported

    "; @@ -254,7 +254,7 @@ FROM `nuke_stories` `t1`, `nuke_authors` `t2`, `nuke_stories_cat` `t3`, `nuke_to } $a = $db->MetaTables('VIEW'); - if ($a===false) print "MetaTables not supported

    "; + if ($a===false) print "MetaTables not supported (views)

    "; else { print "Array of views: "; foreach($a as $v) print " ($v) "; @@ -262,7 +262,7 @@ FROM `nuke_stories` `t1`, `nuke_authors` `t2`, `nuke_stories_cat` `t3`, `nuke_to } $a = $db->MetaTables(false,false,'aDo%'); - if ($a===false) print "MetaTables not supported

    "; + if ($a===false) print "MetaTables not supported (mask)

    "; else { print "Array of ado%: "; foreach($a as $v) print " ($v) "; @@ -287,11 +287,12 @@ FROM `nuke_stories` `t1`, `nuke_authors` `t2`, `nuke_stories_cat` `t3`, `nuke_to } print "

    Testing MetaIndexes

    "; - $a = $db->MetaIndexes('ADOXYZ',true); + + $a = $db->MetaIndexes(('ADOXYZ'),true); if ($a===false) print "MetaIndexes not supported

    "; else { print "

    Indexes of ADOXYZ:
    "; - foreach($a as $v) {print_r($v); echo "
    ";} + adodb_pr($a); echo "
    "; } print "

    Testing MetaPrimaryKeys

    "; @@ -375,7 +376,7 @@ GO rs2html($rs); /* - Test out params - works in 4.2.3 but not 4.3.0???: + Test out params - works in 4.2.3 and 4.3.3 but not 4.3.0: CREATE PROCEDURE at_date_interval @days INTEGER, @@ -577,7 +578,7 @@ END adodb; if (!is_object($rs)) { print_r($rs); err("Update should return object"); - } + } if (!$rs) err("Update generated error"); $nrows = $db->Affected_Rows(); @@ -585,6 +586,15 @@ END adodb; else if ($nrows != $cnt) print "

    Affected_Rows() Error: $nrows returned (should be 50)

    "; else print "

    Affected_Rows() passed

    "; } + + + $array = array('zid'=>1,'zdate'=>date('Y-m-d',time())); + $id = $db->GetOne("select id from ADOXYZ + where id=".$db->Param('zid')." and created>=".$db->Param('ZDATE')."", + $array); + if ($id != 1) Err("Bad bind; id=$id"); + else echo "
    Bind date/integer passed"; + $db->debug = false; $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; @@ -612,7 +622,7 @@ END adodb; } if (empty($HTTP_GET_VARS['hide'])) rs2html($rs); } - else print "Error in Execute of SELECT with random

    "; + else print "

    Error in Execute of SELECT with random

    "; } $val = $db->GetOne("select count(*) from ADOXYZ"); if ($val == 50) print "

    GetOne returns ok

    "; @@ -679,10 +689,17 @@ END adodb; print "

    FETCH_MODE = ASSOC: Should get 1, Caroline

    "; $rs = &$db->SelectLimit('select id,firstname from ADOXYZ order by id',2); if ($rs && !$rs->EOF) { - if ($rs->fields['id'] != 1) {Err("Error 1"); print_r($rs->fields);}; - if (trim($rs->fields['firstname']) != 'Caroline') {Err("Error 2"); print_r($rs->fields);}; + if (ADODB_ASSOC_CASE == 2) { + $id = 'ID'; + $fname = 'FIRSTNAME'; + }else { + $id = 'id'; + $fname = 'firstname'; + } + if ($rs->fields[$id] != 1) {Err("Error 1"); print_r($rs->fields);}; + if (trim($rs->fields[$fname]) != 'Caroline') {Err("Error 2"); print_r($rs->fields);}; $rs->MoveNext(); - if ($rs->fields['id'] != 2) {Err("Error 3"); print_r($rs->fields);}; + if ($rs->fields[$id] != 2) {Err("Error 3"); print_r($rs->fields);}; $rs->MoveNext(); if (!$rs->EOF) Err("Error EOF"); else if (is_array($rs->fields) || $rs->fields) { @@ -884,18 +901,22 @@ END adodb; print "Testing GetAssoc() "; $savecrecs = $ADODB_COUNTRECS; $ADODB_COUNTRECS = false; - $rs = &$db->Execute("select distinct lastname,firstname from ADOXYZ"); + //$arr = $db->GetArray("select lastname,firstname from ADOXYZ"); + //print_r($arr); + print "
    "; + $rs =& $db->Execute("select distinct lastname,firstname from ADOXYZ"); + if ($rs) { $arr = $rs->GetAssoc(); //print_r($arr); - if (trim($arr['See']) != 'Wai Hun') print $arr['See']."   ERROR
    "; + if (empty($arr['See']) || trim($arr['See']) != 'Wai Hun') print $arr['See']."   ERROR
    "; else print " OK 1"; } $arr = &$db->GetAssoc("select distinct lastname,firstname from ADOXYZ"); if ($arr) { //print_r($arr); - if (trim($arr['See']) != 'Wai Hun') print $arr['See']."   ERROR
    "; + if (empty($arr['See']) || trim($arr['See']) != 'Wai Hun') print $arr['See']."   ERROR
    "; else print " OK 2
    "; } // Comment this out to test countrecs = false @@ -1083,10 +1104,11 @@ END adodb; $rs = $db->SelectLimit('select id,firstname,lastname,created,\'The "young man", he said\' from adoxyz',10); - print "
    ";
    -	rs2tabout($rs);
    -	print "
    "; - + if (PHP_VERSION < 5) { + print "
    ";
    +		rs2tabout($rs);
    +		print "
    "; + } //print " CacheFlush "; //$db->CacheFlush(); @@ -1248,7 +1270,7 @@ END adodb; if (!$date) Err("Bad sysDate"); else { $ds = $db->UserDate($date,"d m Y"); - if ($ds != date("d m Y")) Err("Bad UserDate: ".$ds); + if ($ds != date("d m Y")) Err("Bad UserDate: ".$ds.' expected='.date("d m Y")); else echo "Passed UserDate: $ds

    "; } $db->debug=1; @@ -1356,7 +1378,7 @@ END adodb; $conn = NewADOConnection($db->databaseType); $conn->raiseErrorFn = 'adodb_test_err'; - @$conn->Connect('abc'); + @$conn->PConnect('abc'); if ($TESTERRS == 2) print "raiseErrorFn tests passed
    "; else print "raiseErrorFn tests failed ($TESTERRS)
    "; @@ -1398,7 +1420,7 @@ global $TESTERRS,$ERRNO; //-------------------------------------------------------------------------------------- -set_time_limit(240); // increase timeout +@set_time_limit(240); // increase timeout include("../tohtml.inc.php"); include("../adodb.inc.php"); @@ -1418,7 +1440,7 @@ if ( @$HTTP_SERVER_VARS['COMPUTERNAME'] == 'TIGRESS') { CheckWS('firebird'); CheckWS('sybase'); - CheckWS('informix'); + if (!ini_get('safe_mode')) CheckWS('informix'); CheckWS('ado_mssql'); CheckWS('ado_access'); @@ -1429,6 +1451,7 @@ if ( @$HTTP_SERVER_VARS['COMPUTERNAME'] == 'TIGRESS') { CheckWS('db2'); CheckWS('access'); CheckWS('odbc_mssql'); + CheckWS('firebird15'); // CheckWS('oracle'); CheckWS('proxy'); @@ -1463,9 +1486,8 @@ Test GetInsertSQL/GetUpdateSQL   Perf Monitor

    - -vers=",ADOConnection::Version(); include_once('../adodb-time.inc.php'); adodb_date_test(); diff --git a/phpgwapi/inc/adodb/tests/test2.php b/phpgwapi/inc/adodb/tests/test2.php index 8d177b9600..52a2771bac 100644 --- a/phpgwapi/inc/adodb/tests/test2.php +++ b/phpgwapi/inc/adodb/tests/test2.php @@ -8,7 +8,7 @@ Connecting $db->databaseType..."; if (@$db->PConnect("localhost:d:\\firebird\\10\\examples\\employee.gdb", "sysdba", "masterkey", "")) @@ -151,6 +152,21 @@ if (!empty($testmysql)) { // MYSQL } else print "ERROR: MySQL test requires a MySQL server on localhost, userid='admin', password='', database='test'".'
    '.$db->ErrorMsg(); } +// REQUIRES MySQL server at localhost with database 'test' +if (!empty($testmysqli)) { // MYSQL + + $db = &ADONewConnection('mysqli'); + print "

    Connecting $db->databaseType...

    "; + if (PHP_VERSION >= 5 || $HTTP_SERVER_VARS['HTTP_HOST'] == 'localhost') $server = 'localhost'; + else $server = "mangrove"; + if ($db->PConnect($server, "root", "", "northwind")) { + //$db->debug=1;$db->Execute('drop table ADOXYZ'); + testdb($db, + "create table ADOXYZ (id int, firstname char(24), lastname char(24), created date)"); + } else print "ERROR: MySQL test requires a MySQL server on localhost, userid='admin', password='', database='test'".'
    '.$db->ErrorMsg(); +} + + // REQUIRES MySQL server at localhost with database 'test' if (!empty($testmysqlodbc)) { // MYSQL diff --git a/phpgwapi/inc/adodb/tests/testgenid.php b/phpgwapi/inc/adodb/tests/testgenid.php index 6bf8536db8..bc54adac60 100644 --- a/phpgwapi/inc/adodb/tests/testgenid.php +++ b/phpgwapi/inc/adodb/tests/testgenid.php @@ -1,6 +1,6 @@ ExecuteCursor("BEGIN adodb.open_tab(:RS,'A%'); END;"); - $stmt = $db->Prepare("BEGIN adodb.open_tab(:RS,'A%'); END;"); - $db->InParameter($stmt, $cur, 'RS', -1, OCI_B_CURSOR); - $rs = $db->Execute($stmt); - if ($rs && !$rs->EOF) { print "Test 1 RowCount: ".$rs->RecordCount()."

    "; } else { print "Error in using Cursor Variables 1

    "; } - print "

    Testing Stored Procedures for oci8

    "; $stid = $db->PrepareSP('BEGIN adodb.myproc('.MYNUM.', :myov); END;'); diff --git a/phpgwapi/inc/adodb/tests/testpaging.php b/phpgwapi/inc/adodb/tests/testpaging.php index 5bb0229f67..3c5cd640d0 100644 --- a/phpgwapi/inc/adodb/tests/testpaging.php +++ b/phpgwapi/inc/adodb/tests/testpaging.php @@ -1,12 +1,12 @@