diff --git a/composer.json b/composer.json
index 75d0ffe8..f7af4de2 100644
--- a/composer.json
+++ b/composer.json
@@ -5,6 +5,7 @@
"league/plates": "^3.3",
"phpmailer/phpmailer": "^6.0",
"guzzlehttp/guzzle": "^6.3",
- "leafo/scssphp": "^0.7.5"
+ "leafo/scssphp": "^0.7.5",
+ "adodb/adodb-php": "^5.20"
}
}
diff --git a/composer.lock b/composer.lock
index f9dacdfd..78605f91 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,8 +4,62 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
- "content-hash": "7b9fdde15b3d81d1431847e29f201587",
+ "content-hash": "a8d79581e2352baf2677220b715f1348",
"packages": [
+ {
+ "name": "adodb/adodb-php",
+ "version": "v5.20.9",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/ADOdb/ADOdb.git",
+ "reference": "f601748cca1ccb86dfd427620a1692a70e681075"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/ADOdb/ADOdb/zipball/f601748cca1ccb86dfd427620a1692a70e681075",
+ "reference": "f601748cca1ccb86dfd427620a1692a70e681075",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.2"
+ },
+ "type": "library",
+ "autoload": {
+ "files": [
+ "adodb.inc.php"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "BSD-3-Clause",
+ "LGPL-2.1"
+ ],
+ "authors": [
+ {
+ "name": "John Lim",
+ "email": "jlim@natsoft.com",
+ "role": "Author"
+ },
+ {
+ "name": "Damien Regad",
+ "role": "Current maintainer"
+ },
+ {
+ "name": "Mark Newnham",
+ "role": "Developer"
+ }
+ ],
+ "description": "ADOdb is a PHP database abstraction layer library",
+ "homepage": "http://adodb.org/",
+ "keywords": [
+ "abstraction",
+ "database",
+ "layer",
+ "library",
+ "php"
+ ],
+ "time": "2016-12-21T17:19:42+00:00"
+ },
{
"name": "brandonwamboldt/utilphp",
"version": "1.1.0",
diff --git a/f_func/class._DB.php b/f_func/class._DB.php
index 3b7bc593..5e43502f 100644
--- a/f_func/class._DB.php
+++ b/f_func/class._DB.php
@@ -1,6 +1,5 @@
Connect($array,[$types],[$colnames]);
+
+ Parameter $array is the 2 dimensional array of data. The first row can contain the
+ column names. If column names is not defined in first row, you MUST define $colnames,
+ the 3rd parameter.
+
+ Parameter $types is optional. If defined, it should contain an array matching
+ the number of columns in $array, with each element matching the correct type defined
+ by MetaType: (B,C,I,L,N). If undefined, we will probe for $this->_proberows rows
+ to guess the type. Only C,I and N are recognised.
+
+ Parameter $colnames is optional. If defined, it is an array that contains the
+ column names of $array. If undefined, we assume the first row of $array holds the
+ column names.
+
+ The Execute() function will return a recordset. The recordset works like a normal recordset.
+ We have partial support for SQL parsing. We process the SQL using the following rules:
+
+ 1. SQL order by's always work for the first column ordered. Subsequent cols are ignored
+
+ 2. All operations take place on the same table. No joins possible. In fact the FROM clause
+ is ignored! You can use any name for the table.
+
+ 3. To simplify code, all columns are returned, except when selecting 1 column
+
+ $rs = $db->Execute('select col1,col2 from table'); // sql ignored, will generate all cols
+
+ We special case handling of 1 column because it is used in filter popups
+
+ $rs = $db->Execute('select col1 from table');
+ // sql accepted and processed -- any table name is accepted
+
+ $rs = $db->Execute('select distinct col1 from table');
+ // sql accepted and processed
+
+4. Where clauses are ignored, but searching with the 3rd parameter of Execute is permitted.
+ This has to use PHP syntax and we will eval() it. You can even use PHP functions.
+
+ $rs = $db->Execute('select * from table',false,"\$COL1='abc' and $\COL2=3")
+ // the 3rd param is searched -- make sure that $COL1 is a legal column name
+ // and all column names must be in upper case.
+
+4. Group by, having, other clauses are ignored
+
+5. Expression columns, min(), max() are ignored
+
+6. All data is readonly. Only SELECTs permitted.
+*/
+
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+if (! defined("_ADODB_TEXT_LAYER")) {
+ define("_ADODB_TEXT_LAYER", 1 );
+
+// for sorting in _query()
+function adodb_cmp($a, $b) {
+ if ($a[0] == $b[0]) return 0;
+ return ($a[0] < $b[0]) ? -1 : 1;
+}
+// for sorting in _query()
+function adodb_cmpr($a, $b) {
+ if ($a[0] == $b[0]) return 0;
+ return ($a[0] > $b[0]) ? -1 : 1;
+}
+class ADODB_text extends ADOConnection {
+ var $databaseType = 'text';
+
+ var $_origarray; // original data
+ var $_types;
+ var $_proberows = 8;
+ var $_colnames;
+ var $_skiprow1=false;
+ var $readOnly = true;
+ var $hasTransactions = false;
+
+ var $_rezarray;
+ var $_reznames;
+ var $_reztypes;
+
+ function __construct()
+ {
+ }
+
+ function RSRecordCount()
+ {
+ if (!empty($this->_rezarray)) return sizeof($this->_rezarray);
+
+ return sizeof($this->_origarray);
+ }
+
+ function _insertid()
+ {
+ return false;
+ }
+
+ function _affectedrows()
+ {
+ return false;
+ }
+
+ // returns true or false
+ function PConnect(&$array, $types = false, $colnames = false)
+ {
+ return $this->Connect($array, $types, $colnames);
+ }
+ // returns true or false
+ function Connect(&$array, $types = false, $colnames = false)
+ {
+ if (is_string($array) and $array === 'iluvphplens') return 'me2';
+
+ if (!$array) {
+ $this->_origarray = false;
+ return true;
+ }
+ $row = $array[0];
+ $cols = sizeof($row);
+
+
+ if ($colnames) $this->_colnames = $colnames;
+ else {
+ $this->_colnames = $array[0];
+ $this->_skiprow1 = true;
+ }
+ if (!$types) {
+ // probe and guess the type
+ $types = array();
+ $firstrow = true;
+ if ($this->_proberows > sizeof($array)) $max = sizeof($array);
+ else $max = $this->_proberows;
+ for ($j=($this->_skiprow1)?1:0;$j < $max; $j++) {
+ $row = $array[$j];
+ if (!$row) break;
+ $i = -1;
+ foreach($row as $v) {
+ $i += 1;
+ //print " ($i ".$types[$i]. "$v) ";
+ $v = trim($v);
+ if (!preg_match('/^[+-]{0,1}[0-9\.]+$/',$v)) {
+ $types[$i] = 'C'; // once C, always C
+ continue;
+ }
+ if (isset($types[$i]) && $types[$i]=='C') continue;
+ if ($firstrow) {
+ // If empty string, we presume is character
+ // test for integer for 1st row only
+ // after that it is up to testing other rows to prove
+ // that it is not an integer
+ if (strlen($v) == 0) $types[0] = 'C';
+ if (strpos($v,'.') !== false) $types[0] = 'N';
+ else $types[$i] = 'I';
+ continue;
+ }
+
+ if (strpos($v,'.') !== false) $types[$i] = 'N';
+
+ }
+ $firstrow = false;
+ }
+ }
+ //print_r($types);
+ $this->_origarray = $array;
+ $this->_types = $types;
+ return true;
+ }
+
+
+
+ // returns queryID or false
+ // We presume that the select statement is on the same table (what else?),
+ // with the only difference being the order by.
+ //You can filter by using $eval and each clause is stored in $arr .eg. $arr[1] == 'name'
+ // also supports SELECT [DISTINCT] COL FROM ... -- only 1 col supported
+ function _query($sql,$input_arr,$eval=false)
+ {
+ if ($this->_origarray === false) return false;
+
+ $eval = $this->evalAll;
+ $usql = strtoupper(trim($sql));
+ $usql = preg_replace("/[\t\n\r]/",' ',$usql);
+ $usql = preg_replace('/ *BY/i',' BY',strtoupper($usql));
+
+ $eregword ='([A-Z_0-9]*)';
+ //print "
$sql $eval ";
+ if ($eval) {
+ $i = 0;
+ foreach($this->_colnames as $n) {
+ $n = strtoupper(trim($n));
+ $eval = str_replace("\$$n","\$arr[$i]",$eval);
+
+ $i += 1;
+ }
+
+ $i = 0;
+ $eval = "\$rez=($eval);";
+ //print "
Eval string = $eval
"; + $where_arr = array(); + + reset($this->_origarray); + while (list($k_arr,$arr) = each($this->_origarray)) { + + if ($i == 0 && $this->_skiprow1) + $where_arr[] = $arr; + else { + eval($eval); + //print " $i: result=$rez arr[0]={$arr[0]} arr[1]={$arr[1]}",$s.";\n"; + else { + $ok = $this->connDest->Execute($s); + if (!$ok) + if ($this->neverAbort) $ret = false; + else return false; + } + + return $ret; + } + + /* + We assume replication between $table and $desttable only works if the field names and types match for both tables. + + Also $table and desttable can have different names. + */ + + function CopyTableStruct($table,$desttable='') + { + $sql = $this->CopyTableStructSQL($table,$desttable); + if (empty($sql)) return false; + return $this->ExecSQL($sql); + } + + function RunFieldFilter(&$fld, $mode = '') + { + if ($this->fieldFilter) { + $fn = $this->fieldFilter; + return $fn($fld, $mode); + } else + return $fld; + } + + function RunUpdateFilter($table, $fld, $val) + { + if ($this->updateFilter) { + $fn = $this->updateFilter; + return $fn($table, $fld, $val); + } else + return $val; + } + + function RunInsertFilter($table, $fld, &$val) + { + if ($this->insertFilter) { + $fn = $this->insertFilter; + return $fn($table, $fld, $val); + } else + return $fld; + } + + /* + $mode = INS or UPD + + The lastUpdateFld holds the field that counts the number of updates or the date of last mod. This ensures that + if the rec was modified after replicatedata retrieves the data but before we update back the src record, + we don't set the copiedflag='Y' yet. + */ + function RunUpdateSrcFn($srcdb, $table, $fldoffsets, $row, $where, $mode, $dest_insertid=null, $lastUpdateFld='') + { + if (!$this->updateSrcFn) return; + + $bindarr = array(); + foreach($fldoffsets as $k) { + $bindarr[$k] = $row[$k]; + } + $last = sizeof($row); + + if ($lastUpdateFld && $row[$last-1]) { + $ds = $row[$last-1]; + if (strpos($ds,':') !== false) $s = $srcdb->DBTimeStamp($ds); + else $s = $srcdb->qstr($ds); + $where = "WHERE $lastUpdateFld = $s and $where"; + } else + $where = "WHERE $where"; + $fn = $this->updateSrcFn; + if (is_array($fn)) { + if (sizeof($fn) == 1) $set = reset($fn); + else $set = @$fn[$mode]; + if ($set) { + + if (strlen($dest_insertid) == 0) $dest_insertid = 'null'; + $set = str_replace('$INSERT_ID',$dest_insertid,$set); + + $sql = "UPDATE $table SET $set $where "; + $ok = $srcdb->Execute($sql,$bindarr); + if (!$ok) { + echo $srcdb->ErrorMsg(),"
'.$s.''; + + $sqla = $this->ddDest->CreateTableSQL($desttable,$s); + + /* + if ($idxcols) { + $idxoptions = array('UNIQUE'=>1); + $sqla2 = $this->ddDest->_IndexSQL($table.'_'.$fldname.'_SERIAL', $desttable, $idxcols,$idxoptions); + $sqla = array_merge($sqla,$sqla2); + }*/ + + $idxs = $conn->MetaIndexes($table); + if ($idxs) + foreach($idxs as $name => $iarr) { + $idxoptions = array(); + $fldnames = array(); + + if(!empty($iarr['unique'])) { + $idxoptions['UNIQUE'] = 1; + } + + foreach($iarr['columns'] as $fld) { + $fldnames[] = $this->RunFieldFilter($fld,'TABLE'); + } + + $idxname = $prefixidx.str_replace($table,$desttable,$name); + + if (!empty($this->indexFilter)) { + $fn = $this->indexFilter; + $idxname = $fn($desttable,$idxname,$fldnames,$idxoptions); + } + $sqla2 = $this->ddDest->_IndexSQL($idxname, $desttable, $fldnames,$idxoptions); + $sqla = array_merge($sqla,$sqla2); + } + + return $sqla; + } + + function _clearcache() + { + + } + + function _concat($v) + { + return $this->connDest->concat("' ","chr(".ord($v).")","'"); + } + + function fixupbinary($v) + { + return str_replace( + array("\r","\n"), + array($this->_concat("\r"),$this->_concat("\n")), + $v ); + } + + function SwapDBs() + { + $o = $this->connSrc; + $this->connSrc = $this->connDest; + $this->connDest = $o; + + + $o = $this->connSrc2; + $this->connSrc2 = $this->connDest2; + $this->connDest2 = $o; + + $o = $this->ddSrc; + $this->ddSrc = $this->ddDest; + $this->ddDest = $o; + } + + /* + // if no uniqflds defined, then all desttable recs will be deleted before insert + // $where clause must include the WHERE word if used + // if $this->commitRecs is set to a +ve value, then it will autocommit every $this->commitRecs records + // -- this should never be done with 7x24 db's + + Returns an array: + $arr[0] = true if no error, false if error + $arr[1] = number of recs processed + $arr[2] = number of successful inserts + $arr[3] = number of successful updates + + ReplicateData() params: + + $table = src table name + $desttable = dest table name, leave blank to use src table name + $uniqflds = array() = an array. If set, then inserts and updates will occur. eg. array('PK1', 'PK2'); + To prevent updates to desttable (allow only to src table), add '*INSERTONLY*' or '*ONLYINSERT*' to array. + + Sometimes you are replicating a src table with an autoinc primary key. + You sometimes create recs in the dest table. The dest table has to retrieve the + src table's autoinc key (stored in a 2nd field) so you can match the two tables. + + To define this, and the uniqflds contains nested arrays. Copying from autoinc table to other table: + array(array($destpkey), array($destfld_holds_src_autoinc_pkey)) + + Copying from normal table to autoinc table: + array(array($destpkey), array(), array($srcfld_holds_dest_autoinc_pkey)) + + $where = where clause for SELECT from $table $where. Include the WHERE reserved word in beginning. + You can put ORDER BY at the end also + $ignoreflds = array(), list of fields to ignore. e.g. array('FLD1',FLD2'); + $dstCopyDateFld = date field on $desttable to update with current date + $extraflds allows you to add additional flds to insert/update. Format + array(fldname => $fldval) + $fldval itself can be an array or a string. If an array, then + $extraflds = array($fldname => array($insertval, $updateval)) + + Thus we have the following behaviours: + + a. Delete all data in $desttable then insert from src $table + + $rep->execute = true; + $rep->ReplicateData($table, $desttable) + + b. Update $desttable if record exists (based on $uniqflds), otherwise insert. + + $rep->execute = true; + $rep->ReplicateData($table, $desttable, $array($pkey1, $pkey2)) + + c. Select from src $table all data modified since a date. Then update $desttable + if record exists (based on $uniqflds), otherwise insert + + $rep->execute = true; + $rep->ReplicateData($table, $desttable, array($pkey1, $pkey2), "WHERE update_datetime_fld > $LAST_REFRESH") + + d. Insert all records into $desttable modified after a certain id (or time) in src $table: + + $rep->execute = true; + $rep->ReplicateData($table, $desttable, false, "WHERE id_fld > $LAST_ID_SAVED", true); + + + For (a) to (d), returns array: array($boolean_ok_fail, $no_recs_selected_from_src_db, $no_recs_inserted, $no_recs_updated); + + e. Generate sample SQL: + + $rep->execute = false; + $rep->ReplicateData(....); + + This returns $array, which contains: + + $array['SEL'] = select stmt from src db + $array['UPD'] = update stmt to dest db + $array['INS'] = insert stmt to dest db + + + Error-handling + ============== + Default is never abort if error occurs. You can set $rep->neverAbort = false; to force replication to abort if an error occurs. + + + Value Filtering + ======== + Sometimes you might need to modify/massage the data before the code works. Assume that the value used for True and False is + 'T' and 'F' in src DB, but is 'Y' and 'N' in dest DB for field[2] in select stmt. You can do this by + + $rep->filterSelect = 'filter'; + $rep->ReplicateData(...); + + function filter($table,& $fields, $deleteFirst) + { + if ($table == 'SOMETABLE') { + if ($fields[2] == 'T') $fields[2] = 'Y'; + else if ($fields[2] == 'F') $fields[2] = 'N'; + } + } + + We pass in $deleteFirst as that determines the order of the fields (which are numeric-based): + TRUE: the order of fields matches the src table order + FALSE: the order of fields is all non-primary key fields first, followed by primary key fields. This is because it needs + to match the UPDATE statement, which is UPDATE $table SET f2 = ?, f3 = ? ... WHERE f1 = ? + + Name Filtering + ========= + Sometimes field names that are legal in one RDBMS can be illegal in another. + We allow you to handle this using a field filter. + Also if you don't want to replicate certain fields, just return false. + + $rep->fieldFilter = 'ffilter'; + + function ffilter(&$fld,$mode) + { + $uf = strtoupper($fld); + switch($uf) { + case 'GROUP': + if ($mode == 'SELECT') $fld = '"Group"'; + return 'GroupFld'; + + case 'PRIVATEFLD': # do not replicate + return false; + } + return $fld; + } + + + UPDATE FILTERING + ================ + Sometimes, when we want to update + UPDATE table SET fld = val WHERE .... + + we want to modify val. To do so, define + + $rep->updateFilter = 'ufilter'; + + function ufilter($table, $fld, $val) + { + return "nvl($fld, $val)"; + } + + + Sending back audit info back to src Table + ========================================= + + Use $rep->updateSrcFn. This can be an array of strings, or the name of a php function to call. + + If an array of strings is defined, then it will perform an update statement... + + UPDATE srctable SET $string WHERE .... + + With $string set to the array you define. If a new record was inserted into desttable, then the + 'INS' string is used ($INSERT_ID will be replaced with the real INSERT_ID, if any), + and if an update then use the 'UPD' string. + + array( + 'INS' => 'insertid = $INSERT_ID, copieddate=getdate(), copied = 1', + 'UPD' => 'copieddate=getdate(), copied = 1' + ) + + If a single string array is defined, then it will be used for both insert and update. + array('copieddate=getdate(), copied = 1') + + Note that the where clause is automatically defined by the system. + + If $rep->updateSrcFn is a PHP function name, then it will be called with the following params: + + $fn($srcConnection, $tableName, $row, $where, $bindarr, $mode, $dest_insertid) + + $srcConnection - source db connection + $tableName - source tablename + $row - array holding records updated into dest + $where - where clause to be used (uses bind vars) + $bindarr - array holding bind variables for where clause + $mode - INS or UPD + $dest_insertid - when mode=INS, then the insert_id is stored here. + + + oracle mssql + ---> insert + mssqlid <--- insert_id + ----> update with mssqlid + <---- update with mssqlid + + + TODO: add src pkey and dest pkey for updates. Also sql stmt needs to be tuned, so dest pkey, src pkey + */ + + + function ReplicateData($table, $desttable = '', $uniqflds = array(), $where = '',$ignore_flds = array(), + $dstCopyDateFld='', $extraflds = array(), $lastUpdateFld = '') + { + if (is_array($where)) { + $wheresrc = $where[0]; + $wheredest = $where[1]; + } else { + $wheresrc = $wheredest = $where; + } + $dstCopyDateName = $dstCopyDateFld; + $dstCopyDateFld = strtoupper($dstCopyDateFld); + + $this->_clearcache(); + if (is_string($uniqflds) && strlen($uniqflds)) $uniqflds = array($uniqflds); + if (!$desttable) $desttable = $table; + + $uniq = array(); + if ($uniqflds) { + if (is_array(reset($uniqflds))) { + /* + primary key of src and dest tables differ. This means when we perform the select stmts + we retrieve both keys. Then any insert statement will have to ignore one array element. + Any update statement will need to use a different where clause + */ + $destuniqflds = $uniqflds[0]; + if (sizeof($uniqflds)>1 && $uniqflds[1]) // srckey field name in dest table + $srcuniqflds = $uniqflds[1]; + else + $srcuniqflds = array(); + + if (sizeof($uniqflds)>2) + $srcPKDest = reset($uniqflds[2]); + + } else { + $destuniqflds = $uniqflds; + $srcuniqflds = array(); + } + $onlyInsert = false; + foreach($destuniqflds as $k => $u) { + if ($u == '*INSERTONLY*' || $u == '*ONLYINSERT*') { + $onlyInsert = true; + continue; + } + $uniq[strtoupper($u)] = $k; + } + $deleteFirst = $this->deleteFirst; + } else { + $deleteFirst = true; + } + + if ($deleteFirst) $onlyInsert = true; + + if ($ignore_flds) { + foreach($ignore_flds as $u) { + $ignoreflds[strtoupper($u)] = 1; + } + } else + $ignoreflds = array(); + + $src = $this->connSrc; + $dest = $this->connDest; + $src2 = $this->connSrc2; + + $dest->noNullStrings = false; + $src->noNullStrings = false; + $src2->noNullStrings = false; + + if ($src === $dest) $this->execute = false; + + $types = $src->MetaColumns($table); + if (!$types) { + echo "Source $table does not exist
*/
+';
+ if ($deleteFirst && $this->deleteFirst) {
+ $where = preg_replace('/[ \n\r\t]+order[ \n\r\t]+by.*$/i', '', $where);
+ $sql = "DELETE FROM $desttable $wheredest\n";
+ if (!$this->execute) echo $DB2,'*/',$sql,"\n";
+ else $dest->Execute($sql);
+ }
+
+ global $ADODB_COUNTRECS;
+ $err = false;
+ $savemode = $src->setFetchMode(ADODB_FETCH_NUM);
+ $ADODB_COUNTRECS = false;
+
+ if (!$this->execute) {
+ echo $DB1,$sa['SEL'],"\n*/\n\n";
+ echo $DB2,$sa['INS'],"\n*/\n\n";
+ $suffix = ($onlyInsert) ? ' PRIMKEY=?' : '';
+ echo $DB2,$sa['UPD'],"$suffix\n*/\n\n";
+
+ $rs = $src->Execute($sa['SEL']);
+ $cnt = 1;
+ $upd = 0;
+ $ins = 0;
+
+ $sqlarr = explode('?',$sa['INS']);
+ $nparams = sizeof($sqlarr)-1;
+
+ $useQmark = $dest && ($dest->dataProvider != 'oci8');
+
+ while ($rs && !$rs->EOF) {
+ if ($useQmark) {
+ $sql = ''; $i = 0;
+ $arr = array_reverse($rs->fields);
+ //Use each() instead of foreach to reduce memory usage -mikefedyk
+ while(list(, $v) = each($arr)) {
+ $sql .= $sqlarr[$i];
+ // from Ron Baldwin ERROR: $cnt != INS $ins + UPD $upd
"; + $src->setFetchMode($savemode); + return array(!$err, $cnt, $ins, $upd); + } + // trigger support only for sql server and oracle + // need to add + function MergeSrcSetup($srcTable, $pkeys, $srcUpdateDateFld, $srcCopyDateFld, $srcCopyFlagFld, + $srcCopyFlagType='C(1)', $srcCopyFlagVals = array('Y','N','P','=')) + { + $sqla = array(); + $src = $this->connSrc; + $idx = $srcTable.'_mrgIdx'; + $cols = $src->MetaColumns($srcTable); + #adodb_pr($cols); + if (!isset($cols[strtoupper($srcUpdateDateFld)])) { + $sqla = $this->ddSrc->AddColumnSQL($srcTable, "$srcUpdateDateFld TS DEFTIMESTAMP"); + foreach($sqla as $sql) $src->Execute($sql); + } + + if ($srcCopyDateFld && !isset($cols[strtoupper($srcCopyDateFld)])) { + $sqla = $this->ddSrc->AddColumnSQL($srcTable, "$srcCopyDateFld TS DEFTIMESTAMP"); + foreach($sqla as $sql) $src->Execute($sql); + } + + $sysdate = $src->sysTimeStamp; + $arrv0 = $src->qstr($srcCopyFlagVals[0]); + $arrv1 = $src->qstr($srcCopyFlagVals[1]); + $arrv2 = $src->qstr($srcCopyFlagVals[2]); + $arrv3 = $src->qstr($srcCopyFlagVals[3]); + + if ($srcCopyFlagFld && !isset($cols[strtoupper($srcCopyFlagFld)])) { + $sqla = $this->ddSrc->AddColumnSQL($srcTable, "$srcCopyFlagFld $srcCopyFlagType DEFAULT $arrv1"); + foreach($sqla as $sql) $src->Execute($sql); + } + + $sqla = array(); + + + $name = "{$srcTable}_mrgTr"; + if (is_array($pkeys) && strpos($src->databaseType,'mssql') !== false) { + $pk = reset($pkeys); + + #$sqla[] = "DROP TRIGGER $name"; + $sqltr = " + TRIGGER $name + ON $srcTable /* for data replication and merge */ + AFTER UPDATE + AS + UPDATE $srcTable + SET + $srcUpdateDateFld = case when I.$srcCopyFlagFld = $arrv2 or I.$srcCopyFlagFld = $arrv3 then I.$srcUpdateDateFld + else $sysdate end, + $srcCopyFlagFld = case + when I.$srcCopyFlagFld = $arrv2 then $arrv0 + when I.$srcCopyFlagFld = $arrv3 then D.$srcCopyFlagFld + else $arrv1 end + FROM $srcTable S Join Inserted AS I on I.$pk = S.$pk + JOIN Deleted as D ON I.$pk = D.$pk + WHERE I.$srcCopyFlagFld = D.$srcCopyFlagFld or I.$srcCopyFlagFld = $arrv2 + or I.$srcCopyFlagFld = $arrv3 or I.$srcCopyFlagFld is null + "; + $sqla[] = 'CREATE '.$sqltr; // first if does not exists + $sqla[] = 'ALTER '.$sqltr; // second if it already exists + } else if (strpos($src->databaseType,'oci') !== false) { + + if (strlen($srcTable)>22) $tableidx = substr($srcTable,0,16).substr(crc32($srcTable),6); + else $tableidx = $srcTable; + + $name = $tableidx.$this->trgSuffix; + $idx = $tableidx.$this->idxSuffix; + $sqla[] = " +CREATE OR REPLACE TRIGGER $name /* for data replication and merge */ +BEFORE UPDATE ON $srcTable REFERENCING NEW AS NEW OLD AS OLD +FOR EACH ROW +BEGIN + if :new.$srcCopyFlagFld = $arrv2 then + :new.$srcCopyFlagFld := $arrv0; + elsif :new.$srcCopyFlagFld = $arrv3 then + :new.$srcCopyFlagFld := :old.$srcCopyFlagFld; + elsif :old.$srcCopyFlagFld = :new.$srcCopyFlagFld or :new.$srcCopyFlagFld is null then + if $this->trLogic then + :new.$srcUpdateDateFld := $sysdate; + :new.$srcCopyFlagFld := $arrv1; + end if; + end if; +END; +"; + } + foreach($sqla as $sql) $src->Execute($sql); + + if ($srcCopyFlagFld) $srcCopyFlagFld .= ', '; + $src->Execute("CREATE INDEX {$idx} on $srcTable ($srcCopyFlagFld$srcUpdateDateFld)"); + } + + + /* + Perform Merge by copying all data modified from src to dest + then update src copied flag if present. + + Returns array taken from ReplicateData: + + Returns an array: + $arr[0] = true if no error, false if error + $arr[1] = number of recs processed + $arr[2] = number of successful inserts + $arr[3] = number of successful updates + + $srcTable = src table + $dstTable = dest table + $pkeys = primary keys array. if empty, then only inserts will occur + $srcignoreflds = ignore these flds (must be upper cased) + $setsrc = updateSrcFn string + $srcUpdateDateFld = field in src with the last update date + $srcCopyFlagFld = false = optional field that holds the copied indicator + $flagvals=array('Y','N','P','=') = array of values indicating array(copied, not copied). + Null is assumed to mean not copied. The 3rd value 'P' indicates that we want to force 'Y', bypassing + default trigger behaviour to reset the COPIED='N' when the record is replicated from other side. + The last value '=' is don't change copyflag. + $srcCopyDateFld = field that holds last copy date in src table, which will be updated on Merge() + $dstCopyDateFld = field that holds last copy date in dst table, which will be updated on Merge() + $defaultDestRaiseErrorFn = The adodb raiseErrorFn handler. Default is to not raise an error. + Just output error message to stdout + + */ + + + function Merge($srcTable, $dstTable, $pkeys, $srcignoreflds, $setsrc, + $srcUpdateDateFld, + $srcCopyFlagFld, $flagvals=array('Y','N','P','='), + $srcCopyDateFld = false, + $dstCopyDateFld = false, + $whereClauses = '', + $orderBy = '', # MUST INCLUDE THE "ORDER BY" suffix + $copyDoneFlagIdx = 3, + $defaultDestRaiseErrorFn = '') + { + $src = $this->connSrc; + $dest = $this->connDest; + + $time = $src->Time(); + + $delfirst = $this->deleteFirst; + $upd = $this->updateSrcFn; + + $this->deleteFirst = false; + //$this->updateFirst = true; + + $srcignoreflds[] = $srcUpdateDateFld; + $srcignoreflds[] = $srcCopyFlagFld; + $srcignoreflds[] = $srcCopyDateFld; + + if (empty($whereClauses)) $whereClauses = '1=1'; + $where = " WHERE ($whereClauses) and ($srcCopyFlagFld = ".$src->qstr($flagvals[1]).')'; + if ($orderBy) $where .= ' '.$orderBy; + else $where .= ' ORDER BY '.$srcUpdateDateFld; + + if ($setsrc) $set[] = $setsrc; + else $set = array(); + + if ($srcCopyFlagFld) $set[] = "$srcCopyFlagFld = ".$src->qstr($flagvals[2]); + if ($srcCopyDateFld) $set[]= "$srcCopyDateFld = ".$src->sysTimeStamp; + if ($set) $this->updateSrcFn = array(implode(', ',$set)); + else $this->updateSrcFn = ''; + + + $extra[$srcCopyFlagFld] = array($dest->qstr($flagvals[0]),$dest->qstr($flagvals[$copyDoneFlagIdx])); + + $saveraise = $dest->raiseErrorFn; + $dest->raiseErrorFn = ''; + + if ($this->compat && $this->compat == 1.0) $srcUpdateDateFld = ''; + $arr = $this->ReplicateData($srcTable, $dstTable, $pkeys, $where, $srcignoreflds, + $dstCopyDateFld,$extra,$srcUpdateDateFld); + + $dest->raiseErrorFn = $saveraise; + + $this->updateSrcFn = $upd; + $this->deleteFirst = $delfirst; + + return $arr; + } + /* + If doing a 2 way merge, then call + $rep->Merge() + to save without modifying the COPIEDFLAG ('='). + + Then can the following to set the COPIEDFLAG to 'P' which forces the COPIEDFLAG = 'Y' + $rep->MergeDone() + */ + + function MergeDone($srcTable, $dstTable, $pkeys, $srcignoreflds, $setsrc, + $srcUpdateDateFld, + $srcCopyFlagFld, $flagvals=array('Y','N','P','='), + $srcCopyDateFld = false, + $dstCopyDateFld = false, + $whereClauses = '', + $orderBy = '', # MUST INCLUDE THE "ORDER BY" suffix + $copyDoneFlagIdx = 2, + $defaultDestRaiseErrorFn = '') + { + return $this->Merge($srcTable, $dstTable, $pkeys, $srcignoreflds, $setsrc, + $srcUpdateDateFld, + $srcCopyFlagFld, $flagvals, + $srcCopyDateFld, + $dstCopyDateFld, + $whereClauses, + $orderBy, # MUST INCLUDE THE "ORDER BY" suffix + $copyDoneFlagIdx, + $defaultDestRaiseErrorFn); + } + + function _doerr($reason, $selflds) + { + $fn = $this->errHandler; + if ($fn) $fn($this, $reason, $selflds); // set $this->neverAbort to true or false as required inside $fn + } +} diff --git a/vendor/adodb/adodb-php/replicate/replicate-steps.php b/vendor/adodb/adodb-php/replicate/replicate-steps.php new file mode 100644 index 00000000..5b696568 --- /dev/null +++ b/vendor/adodb/adodb-php/replicate/replicate-steps.php @@ -0,0 +1,137 @@ +Connect($HOST,$USER,$PWD,$DBASE); +if (!$ok) return; + + +#$DB->debug=1; + +$bkup = 'tmp'.date('ymd_His'); + + +if ($BA) { + $QTY_BA = " and qu_bacode='$BA'"; + if (1) $STP_BA = " and s_stagecat in (select stg_stagecat from kbstage where stg_bacode='$BA')"; # OLDER KBSTEP + else $STP_BA = " and s_bacode='$BA'"; # LATEST KBSTEP format + $STG_BA = " and stg_bacode='$BA'"; +} else { + $QTY_BA = ""; + $STP_BA = ""; + $STG_BA = ""; +} + +if ($STAGES) { + + $STAGES = explode(',',$STAGES); + $STAGES = "'".implode("','",$STAGES)."'"; + $QTY_STG = " and qu_stagecat in ($STAGES)"; + $STP_STG = " and s_stagecat in ($STAGES)"; + $STG_STG = " and stg_stagecat in ($STAGES)"; +} else { + $QTY_STG = ""; + $STP_STG = ""; + $STG_STG = ""; +} + +echo "
+
+/******************************************************************************
+
+ Migrate stages, steps and qtypes for the following
+
+ business area: $BA
+ and stages: $STAGES
+
+
+ WARNING: DO NOT 'Ignore All Errors'.
+ If any error occurs, make sure you stop and check the reason and fix it.
+ Otherwise you could corrupt everything!!!
+
+ Connected to $USER@$DBASE $HOST;
+
+*******************************************************************************/
+
+-- BACKUP
+create table kbstage_$bkup as select * from kbstage;
+create table kbstep_$bkup as select * from kbstep;
+create table kbqtype_$bkup as select * from kbqtype;
+
+
+-- IF CODE FAILS, REMEMBER TO RENABLE ALL TRIGGERS and following CONSTRAINT
+ALTER TABLE kbstage DISABLE all triggers;
+ALTER TABLE kbstep DISABLE all triggers;
+ALTER TABLE kbqtype DISABLE all triggers;
+ALTER TABLE jqueue DISABLE CONSTRAINT QUEUE_MUST_HAVE_TYPE;
+
+
+-- NOW DELETE OLD STEPS/STAGES/QUEUES
+delete from kbqtype where qu_mode in ('STAGE','STEP') $QTY_BA $QTY_STG;
+delete from kbstep where (1=1) $STP_BA$STP_STG;
+delete from kbstage where (1=1)$STG_BA$STG_STG;
+
+
+
+SET DEFINE OFF; -- disable variable handling by sqlplus
+/
+/* Assume kbstrategy and business areas are compatible for steps and stages to be copied */
+
+
+";
+
+
+$rep = new ADODB_Replicate($DB,$DB);
+$rep->execute = false;
+$rep->deleteFirst = false;
+
+ // src table name, dst table name, primary key, where condition
+$rep->ReplicateData('KBSTAGE', 'KBSTAGE', array(), " where (1=1)$STG_BA$STG_STG");
+$rep->ReplicateData('KBSTEP', 'KBSTEP', array(), " where (1=1)$STP_BA$STP_STG");
+$rep->ReplicateData('KBQTYPE','KBQTYPE',array()," where qu_mode in ('STAGE','STEP')$QTY_BA$QTY_STG");
+
+echo "
+
+-- Check for QUEUES not in KBQTYPE and FIX by copying from kbqtype_$bkup
+begin
+for rec in (select distinct q_type from jqueue where q_type not in (select qu_code from kbqtype)) loop
+ insert into kbqtype select * from kbqtype_$bkup where qu_code = rec.q_type;
+ update kbqtype set qu_name=substr('MISSING.'||qu_name,1,64) where qu_code=rec.q_type;
+end loop;
+end;
+/
+
+commit;
+
+
+ALTER TABLE kbstage ENABLE all triggers;
+ALTER TABLE kbstep ENABLE all triggers;
+ALTER TABLE kbqtype ENABLE all triggers;
+ALTER TABLE jqueue ENABLE CONSTRAINT QUEUE_MUST_HAVE_TYPE;
+
+/*
+-- REMEMBER TO COMMIT
+ commit;
+ begin Juris.UpdateQCounts; end;
+
+-- To check for bad queues after conversion, run this
+ select * from kbqtype where qu_name like 'MISSING%'
+*/
+/
+";
diff --git a/vendor/adodb/adodb-php/replicate/test-tnb.php b/vendor/adodb/adodb-php/replicate/test-tnb.php
new file mode 100644
index 00000000..f163ff4f
--- /dev/null
+++ b/vendor/adodb/adodb-php/replicate/test-tnb.php
@@ -0,0 +1,421 @@
+ 28) $idxname = substr($idxname,0,24).rand(1000,9999);
+ return $idxname;
+}
+
+function SelFilter($table, &$arr, $delfirst)
+{
+ return true;
+}
+
+function updatefilter($table, $fld, $val)
+{
+ return "nvl($fld, $val)";
+}
+
+
+function FieldFilter(&$fld,$mode)
+{
+ $uf = strtoupper($fld);
+ switch($uf) {
+ case 'SIZEFLD':
+ return 'Size';
+
+ case 'GROUPFLD':
+ return 'Group';
+
+ case 'GROUP':
+ if ($mode == 'SELECT') $fld = '"Group"';
+ return 'GroupFld';
+ case 'SIZE':
+ if ($mode == 'SELECT') $fld = '"Size"';
+ return 'SizeFld';
+ }
+ return $fld;
+}
+
+function ParseTable(&$table, &$pkey)
+{
+ $table = trim($table);
+ if (strlen($table) == 0) return false;
+ if (strpos($table, '#') !== false) {
+ $at = strpos($table, '#');
+ $table = trim(substr($table,0,$at));
+ if (strlen($table) == 0) return false;
+ }
+
+ $tabarr = explode(',',$table);
+ if (sizeof($tabarr) == 1) {
+ $table = $tabarr[0];
+ $pkey = '';
+ echo "No primary key for $table **** **** "; + return; + } + $arr = $rs->GetArray(); + //$db->debug = true; + global $ADODB_COUNTRECS; + $ADODB_COUNTRECS = false; + $start = microtime(); + for ($i=0; $i < $max; $i++) { + $rs = $db->Execute($sql); + $arr = $rs->GetArray(); + // print $arr[0][1]; + } + $end = microtime(); + $start = explode(' ',$start); + $end = explode(' ',$end); + + //print_r($start); + //print_r($end); + + // print_r($arr); + $total = $end[0]+trim($end[1]) - $start[0]-trim($start[1]); + printf ("
seconds = %8.2f for %d iterations each with %d records
",$total,$max, sizeof($arr)); + flush(); + + + //$db->Close(); +} +include("testdatabases.inc.php"); + +?> + + + + diff --git a/vendor/adodb/adodb-php/tests/client.php b/vendor/adodb/adodb-php/tests/client.php new file mode 100644 index 00000000..5b30065a --- /dev/null +++ b/vendor/adodb/adodb-php/tests/client.php @@ -0,0 +1,199 @@ + + +'; + var_dump(parse_url('odbc_mssql://userserver/')); + die(); + +include('../adodb.inc.php'); +include('../tohtml.inc.php'); + + function send2server($url,$sql) + { + $url .= '?sql='.urlencode($sql); + print "$url
"; + $rs = csv2rs($url,$err); + if ($err) print $err; + return $rs; + } + + function print_pre($s) + { + print "";print_r($s);print ""; + } + + +$serverURL = 'http://localhost/php/phplens/adodb/server.php'; +$testhttp = false; + +$sql1 = "insertz into products (productname) values ('testprod 1')"; +$sql2 = "insert into products (productname) values ('testprod 1')"; +$sql3 = "insert into products (productname) values ('testprod 2')"; +$sql4 = "delete from products where productid>80"; +$sql5 = 'select * from products'; + +if ($testhttp) { + print "Client Driver Tests
"; + print "
"; + echo $e; + echo ""; +} diff --git a/vendor/adodb/adodb-php/tests/test-active-record.php b/vendor/adodb/adodb-php/tests/test-active-record.php new file mode 100644 index 00000000..59471620 --- /dev/null +++ b/vendor/adodb/adodb-php/tests/test-active-record.php @@ -0,0 +1,140 @@ += 5) { + include('../adodb-exceptions.inc.php'); + echo "
Output of getAttributeNames: "; + var_dump($person->getAttributeNames()); + + /** + * Outputs the following: + * array(4) { + * [0]=> + * string(2) "id" + * [1]=> + * string(9) "name_first" + * [2]=> + * string(8) "name_last" + * [3]=> + * string(13) "favorite_color" + * } + */ + + $person = new Person(); + $person->name_first = 'Andi'; + $person->name_last = 'Gutmans'; + $person->save(); // this save() will fail on INSERT as favorite_color is a must fill... + + + $person = new Person(); + $person->name_first = 'Andi'; + $person->name_last = 'Gutmans'; + $person->favorite_color = 'blue'; + $person->save(); // this save will perform an INSERT successfully + + echo "
The Insert ID generated:"; print_r($person->id); + + $person->favorite_color = 'red'; + $person->save(); // this save() will perform an UPDATE + + $person = new Person(); + $person->name_first = 'John'; + $person->name_last = 'Lim'; + $person->favorite_color = 'lavender'; + $person->save(); // this save will perform an INSERT successfully + + // load record where id=2 into a new ADOdb_Active_Record + $person2 = new Person(); + $person2->Load('id=2'); + + $activeArr = $db->GetActiveRecordsClass($class = "Person",$table = "Persons","id=".$db->Param(0),array(2)); + $person2 = $activeArr[0]; + echo "
Name (should be John): ",$person->name_first, "
Class (should be Person): ",get_class($person2),"
";
+
+ $db->Execute("insert into children (person_id,name_first,name_last) values (2,'Jill','Lim')");
+ $db->Execute("insert into children (person_id,name_first,name_last) values (2,'Joan','Lim')");
+ $db->Execute("insert into children (person_id,name_first,name_last) values (2,'JAMIE','Lim')");
+
+ $newperson2 = new Person();
+ $person2->HasMany('children','person_id');
+ $person2->Load('id=2');
+ $person2->name_last='green';
+ $c = $person2->children;
+ $person2->save();
+
+ if (is_array($c) && sizeof($c) == 3 && $c[0]->name_first=='Jill' && $c[1]->name_first=='Joan'
+ && $c[2]->name_first == 'JAMIE') echo "OK Loaded HasMany";
+ else {
+ var_dump($c);
+ echo "error loading hasMany should have 3 array elements Jill Joan Jamie
";
+ }
+
+ class Child extends ADOdb_Active_Record{};
+ $ch = new Child('children',array('id'));
+ $ch->BelongsTo('person','person_id','id');
+ $ch->Load('id=1');
+ if ($ch->name_first !== 'Jill') echo "error in Loading Child
";
+
+ $p = $ch->person;
+ if ($p->name_first != 'John') echo "Error loading belongsTo
";
+ else echo "OK loading BelongTo
";
+
+ $p->hasMany('children','person_id');
+ $p->LoadRelations('children', " Name_first like 'J%' order by id",1,2);
+ if (sizeof($p->children) == 2 && $p->children[1]->name_first == 'JAMIE') echo "OK LoadRelations
";
+ else echo "error LoadRelations
";
+
+ $db->Execute("CREATE TEMPORARY TABLE `persons2` (
+ `id` int(10) unsigned NOT NULL auto_increment,
+ `name_first` varchar(100) NOT NULL default '',
+ `name_last` varchar(100) NOT NULL default '',
+ `favorite_color` varchar(100) default '',
+ PRIMARY KEY (`id`)
+ ) ENGINE=MyISAM;
+ ");
+
+ $p = new adodb_active_record('persons2');
+ $p->name_first = 'James';
+
+ $p->name_last = 'James';
+
+ $p->HasMany('children','person_id');
+ $p->children;
+ var_dump($p);
+ $p->Save();
diff --git a/vendor/adodb/adodb-php/tests/test-active-recs2.php b/vendor/adodb/adodb-php/tests/test-active-recs2.php
new file mode 100644
index 00000000..f5898fcd
--- /dev/null
+++ b/vendor/adodb/adodb-php/tests/test-active-recs2.php
@@ -0,0 +1,76 @@
+Connect("localhost","tester","test","test");
+} else
+ $db = NewADOConnection('oci8://scott:natsoft@/');
+
+
+$arr = $db->ServerInfo();
+echo "
Affected Rows after delete=".$db->Affected_Rows()."
"; diff --git a/vendor/adodb/adodb-php/tests/test-active-relations.php b/vendor/adodb/adodb-php/tests/test-active-relations.php new file mode 100644 index 00000000..7a98d479 --- /dev/null +++ b/vendor/adodb/adodb-php/tests/test-active-relations.php @@ -0,0 +1,85 @@ +debug=1; + ADOdb_Active_Record::SetDatabaseAdapter($db); + + $db->Execute("CREATE TEMPORARY TABLE `persons` ( + `id` int(10) unsigned NOT NULL auto_increment, + `name_first` varchar(100) NOT NULL default '', + `name_last` varchar(100) NOT NULL default '', + `favorite_color` varchar(100) NOT NULL default '', + PRIMARY KEY (`id`) + ) ENGINE=MyISAM; + "); + + $db->Execute("CREATE TEMPORARY TABLE `children` ( + `id` int(10) unsigned NOT NULL auto_increment, + `person_id` int(10) unsigned NOT NULL, + `name_first` varchar(100) NOT NULL default '', + `name_last` varchar(100) NOT NULL default '', + `favorite_pet` varchar(100) NOT NULL default '', + PRIMARY KEY (`id`) + ) ENGINE=MyISAM; + "); + + + $db->Execute("insert into children (person_id,name_first,name_last) values (1,'Jill','Lim')"); + $db->Execute("insert into children (person_id,name_first,name_last) values (1,'Joan','Lim')"); + $db->Execute("insert into children (person_id,name_first,name_last) values (1,'JAMIE','Lim')"); + + ADODB_Active_Record::TableHasMany('persons', 'children','person_id'); + class person extends ADOdb_Active_Record{} + + $person = new person(); +# $person->HasMany('children','person_id'); ## this is affects all other instances of Person + + $person->name_first = 'John'; + $person->name_last = 'Lim'; + $person->favorite_color = 'lavender'; + $person->save(); // this save will perform an INSERT successfully + + $person2 = new person(); + $person2->Load('id=1'); + + $c = $person2->children; + if (is_array($c) && sizeof($c) == 3 && $c[0]->name_first=='Jill' && $c[1]->name_first=='Joan' + && $c[2]->name_first == 'JAMIE') echo "OK Loaded HasMany"; + else { + var_dump($c); + echo "error loading hasMany should have 3 array elements Jill Joan Jamie"; + $db = NewADOConnection($dbType); + $dict = NewDataDictionary($db); + + if (!$dict) continue; + $dict->debug = 1; + + $opts = array('REPLACE','mysql' => 'ENGINE=INNODB', 'oci8' => 'TABLESPACE USERS'); + +/* $flds = array( + array('id', 'I', + 'AUTO','KEY'), + + array('name' => 'firstname', 'type' => 'varchar','size' => 30, + 'DEFAULT'=>'Joan'), + + array('lastname','varchar',28, + 'DEFAULT'=>'Chen','key'), + + array('averylonglongfieldname','X',1024, + 'NOTNULL','default' => 'test'), + + array('price','N','7.2', + 'NOTNULL','default' => '0.00'), + + array('MYDATE', 'D', + 'DEFDATE'), + array('TS','T', + 'DEFTIMESTAMP') + );*/ + + $flds = " +ID I AUTO KEY, +FIRSTNAME VARCHAR(30) DEFAULT 'Joan' INDEX idx_name, +LASTNAME VARCHAR(28) DEFAULT 'Chen' key INDEX idx_name INDEX idx_lastname, +averylonglongfieldname X(1024) DEFAULT 'test', +price N(7.2) DEFAULT '0.00', +MYDATE D DEFDATE INDEX idx_date, +BIGFELLOW X NOTNULL, +TS_SECS T DEFTIMESTAMP, +TS_SUBSEC TS DEFTIMESTAMP +"; + + + $sqla = $dict->CreateDatabase('KUTU',array('postgres'=>"LOCATION='/u01/postdata'")); + $dict->SetSchema('KUTU'); + + $sqli = ($dict->CreateTableSQL('testtable',$flds, $opts)); + $sqla = array_merge($sqla,$sqli); + + $sqli = $dict->CreateIndexSQL('idx','testtable','price,firstname,lastname',array('BITMAP','FULLTEXT','CLUSTERED','HASH')); + $sqla = array_merge($sqla,$sqli); + $sqli = $dict->CreateIndexSQL('idx2','testtable','price,lastname');//,array('BITMAP','FULLTEXT','CLUSTERED')); + $sqla = array_merge($sqla,$sqli); + + $addflds = array(array('height', 'F'),array('weight','F')); + $sqli = $dict->AddColumnSQL('testtable',$addflds); + $sqla = array_merge($sqla,$sqli); + $addflds = array(array('height', 'F','NOTNULL'),array('weight','F','NOTNULL')); + $sqli = $dict->AlterColumnSQL('testtable',$addflds); + $sqla = array_merge($sqla,$sqli); + + + printsqla($dbType,$sqla); + + if (file_exists('d:\inetpub\wwwroot\php\phplens\adodb\adodb.inc.php')) + if ($dbType == 'mysqlt') { + $db->Connect('localhost', "root", "", "test"); + $dict->SetSchema(''); + $sqla2 = $dict->ChangeTableSQL('adoxyz',$flds); + if ($sqla2) printsqla($dbType,$sqla2); + } + if ($dbType == 'postgres') { + if (@$db->Connect('localhost', "tester", "test", "test")); + $dict->SetSchema(''); + $sqla2 = $dict->ChangeTableSQL('adoxyz',$flds); + if ($sqla2) printsqla($dbType,$sqla2); + } + + if ($dbType == 'odbc_mssql') { + $dsn = $dsn = "PROVIDER=MSDASQL;Driver={SQL Server};Server=localhost;Database=northwind;"; + if (@$db->Connect($dsn, "sa", "natsoft", "test")); + $dict->SetSchema(''); + $sqla2 = $dict->ChangeTableSQL('adoxyz',$flds); + if ($sqla2) printsqla($dbType,$sqla2); + } + + + + adodb_pr($dict->databaseType); + printsqla($dbType, $dict->DropColumnSQL('table',array('my col','`col2_with_Quotes`','A_col3','col3(10)'))); + printsqla($dbType, $dict->ChangeTableSQL('adoxyz','LASTNAME varchar(32)')); + +} + +function printsqla($dbType,$sqla) +{ + print "
";
+ //print_r($dict->MetaTables());
+ foreach($sqla as $s) {
+ $s = htmlspecialchars($s);
+ print "$s;\n";
+ if ($dbType == 'oci8') print "/\n";
+ }
+ print ""; +foreach($ff as $xml) echo htmlspecialchars($xml); +echo ""; +include_once('test-xmlschema.php'); diff --git a/vendor/adodb/adodb-php/tests/test-perf.php b/vendor/adodb/adodb-php/tests/test-perf.php new file mode 100644 index 00000000..62465bef --- /dev/null +++ b/vendor/adodb/adodb-php/tests/test-perf.php @@ -0,0 +1,48 @@ + $v) { + if (strncmp($k,'test',4) == 0) $_SESSION['_db'] = $k; + } +} + +if (isset($_SESSION['_db'])) { + $_db = $_SESSION['_db']; + $_GET[$_db] = 1; + $$_db = 1; +} + +echo "
'; + echo $perf->HealthCheck(); + echo($perf->SuspiciousSQL()); + echo($perf->ExpensiveSQL()); + echo($perf->InvalidSQL()); + echo $perf->Tables(); + + echo "
";
+ echo $perf->HealthCheckCLI();
+ $perf->Poll(3);
+ die();
+ }
+
+ if ($perf) $perf->UI(3);
+}
diff --git a/vendor/adodb/adodb-php/tests/test-pgblob.php b/vendor/adodb/adodb-php/tests/test-pgblob.php
new file mode 100644
index 00000000..3add99e6
--- /dev/null
+++ b/vendor/adodb/adodb-php/tests/test-pgblob.php
@@ -0,0 +1,86 @@
+Param(false);
+ $x = (rand() % 10) + 1;
+ $db->debug= ($i==1);
+ $id = $db->GetOne($sql,
+ array('Z%','Z%',$x));
+ if($id != $offset+$x) {
+ print "Error at $x";
+ break;
+ }
+ }
+}
+
+include_once('../adodb.inc.php');
+$db = NewADOConnection('postgres7');
+$db->PConnect('localhost','tester','test','test') || die("failed connection");
+
+$enc = "GIF89a%01%00%01%00%80%FF%00%C0%C0%C0%00%00%00%21%F9%04%01%00%00%00%00%2C%00%00%00%00%01%00%01%00%00%01%012%00%3Bt_clear.gif%0D";
+$val = rawurldecode($enc);
+
+$MAX = 1000;
+
+adodb_pr($db->ServerInfo());
+
+echo "
Testing PREPARE/EXECUTE PLAN
";
+
+
+$db->_bindInputArray = true; // requires postgresql 7.3+ and ability to modify database
+$t = getmicrotime();
+doloop();
+echo '',$MAX,' times, with plan=',getmicrotime() - $t,'
';
+
+
+$db->_bindInputArray = false;
+$t = getmicrotime();
+doloop();
+echo '',$MAX,' times, no plan=',getmicrotime() - $t,'
';
+
+
+
+echo "Testing UPDATEBLOB
";
+$db->debug=1;
+
+### TEST BEGINS
+
+$db->Execute("insert into photos (id,name) values(9999,'dot.gif')");
+$db->UpdateBlob('photos','photo',$val,'id=9999');
+$v = $db->GetOne('select photo from photos where id=9999');
+
+
+### CLEANUP
+
+$db->Execute("delete from photos where id=9999");
+
+### VALIDATION
+
+if ($v !== $val) echo "*** ERROR: Inserted value does not match downloaded val";
+else echo "*** OK: Passed";
+
+echo "";
+echo "INSERTED: ", $enc;
+echo "
";
+echo"RETURNED: ", rawurlencode($v);
+echo "
";
+echo "INSERTED: ", $val;
+echo "
";
+echo "RETURNED: ", $v;
diff --git a/vendor/adodb/adodb-php/tests/test-php5.php b/vendor/adodb/adodb-php/tests/test-php5.php
new file mode 100644
index 00000000..a8f1ffe5
--- /dev/null
+++ b/vendor/adodb/adodb-php/tests/test-php5.php
@@ -0,0 +1,116 @@
+PHP ".PHP_VERSION."\n";
+try {
+
+$dbt = 'oci8po';
+
+try {
+switch($dbt) {
+case 'oci8po':
+ $db = NewADOConnection("oci8po");
+
+ $db->Connect('localhost','scott','natsoft','sherkhan');
+ break;
+default:
+case 'mysql':
+ $db = NewADOConnection("mysql");
+ $db->Connect('localhost','root','','northwind');
+ break;
+
+case 'mysqli':
+ $db = NewADOConnection("mysqli://root:@localhost/northwind");
+ //$db->Connect('localhost','root','','test');
+ break;
+}
+} catch (exception $e){
+ echo "Connect Failed";
+ adodb_pr($e);
+ die();
+}
+
+$db->debug=1;
+
+$cnt = $db->GetOne("select count(*) from adoxyz where ?Prepare("select * from adoxyz where ?ErrorMsg(),"\n";
+$rs = $db->Execute($stmt,array(10,20));
+
+echo "
Foreach Iterator Test (rand=".rand().")
";
+$i = 0;
+foreach($rs as $v) {
+ $i += 1;
+ echo "rec $i: "; $s1 = adodb_pr($v,true); $s2 = adodb_pr($rs->fields,true);
+ if ($s1 != $s2 && !empty($v)) {adodb_pr($s1); adodb_pr($s2);}
+ else echo "passed
";
+ flush();
+}
+
+$rs = new ADORecordSet_empty();
+foreach($rs as $v) {
+ echo "empty ";var_dump($v);
+}
+
+
+if ($i != $cnt) die("actual cnt is $i, cnt should be $cnt\n");
+else echo "Count $i is correct
";
+
+$rs = $db->Execute("select bad from badder");
+
+} catch (exception $e) {
+ adodb_pr($e);
+ echo "
adodb_backtrace:
\n";
+ $e = adodb_backtrace($e->gettrace());
+}
+
+$rs = $db->Execute("select distinct id, firstname,lastname from adoxyz order by id");
+echo "Result=\n",$rs,"";
+
+echo "Active Record
";
+
+ include_once("../adodb-active-record.inc.php");
+ ADOdb_Active_Record::SetDatabaseAdapter($db);
+
+try {
+ class City extends ADOdb_Active_Record{};
+ $a = new City();
+
+} catch(exception $e){
+ echo $e->getMessage();
+}
+
+try {
+
+ $a = new City();
+
+ echo "Successfully created City()
";
+ #var_dump($a->GetPrimaryKeys());
+ $a->city = 'Kuala Lumpur';
+ $a->Save();
+ $a->Update();
+ #$a->SetPrimaryKeys(array('city'));
+ $a->country = "M'sia";
+ $a->save();
+ $a->Delete();
+} catch(exception $e){
+ echo $e->getMessage();
+}
+
+//include_once("test-active-record.php");
diff --git a/vendor/adodb/adodb-php/tests/test-xmlschema.php b/vendor/adodb/adodb-php/tests/test-xmlschema.php
new file mode 100644
index 00000000..c56cfec8
--- /dev/null
+++ b/vendor/adodb/adodb-php/tests/test-xmlschema.php
@@ -0,0 +1,53 @@
+Connect( 'localhost', 'root', '', 'test' ) || die('fail connect1');
+
+// To create a schema object and build the query array.
+$schema = new adoSchema( $db );
+
+// To upgrade an existing schema object, use the following
+// To upgrade an existing database to the provided schema,
+// uncomment the following line:
+#$schema->upgradeSchema();
+
+print "SQL to build xmlschema.xml:\n
";
+// Build the SQL array
+$sql = $schema->ParseSchema( "xmlschema.xml" );
+
+var_dump( $sql );
+print "
\n";
+
+// Execute the SQL on the database
+//$result = $schema->ExecuteSchema( $sql );
+
+// Finally, clean up after the XML parser
+// (PHP won't do this for you!)
+//$schema->Destroy();
+
+
+
+print "SQL to build xmlschema-mssql.xml:\n";
+
+$db2 = ADONewConnection('mssql');
+$db2->Connect('','adodb','natsoft','northwind') || die("Fail 2");
+
+$db2->Execute("drop table simple_table");
+
+$schema = new adoSchema( $db2 );
+$sql = $schema->ParseSchema( "xmlschema-mssql.xml" );
+
+print_r( $sql );
+print "\n";
+
+$db2->debug=1;
+
+foreach ($sql as $s)
+$db2->Execute($s);
diff --git a/vendor/adodb/adodb-php/tests/test.php b/vendor/adodb/adodb-php/tests/test.php
new file mode 100644
index 00000000..50e74ad4
--- /dev/null
+++ b/vendor/adodb/adodb-php/tests/test.php
@@ -0,0 +1,1781 @@
+$msg
";
+ flush();
+}
+
+function CheckWS($conn)
+{
+global $ADODB_EXTENSION;
+
+ include_once('../session/adodb-session.php');
+ if (defined('CHECKWSFAIL')){ echo " TESTING $conn ";flush();}
+ $saved = $ADODB_EXTENSION;
+ $db = ADONewConnection($conn);
+ $ADODB_EXTENSION = $saved;
+ if (headers_sent()) {
+ print "White space detected in adodb-$conn.inc.php or include file...
";
+ //die();
+ }
+}
+
+function do_strtolower(&$arr)
+{
+ foreach($arr as $k => $v) {
+ if (is_object($v)) $arr[$k] = adodb_pr($v,true);
+ else $arr[$k] = strtolower($v);
+ }
+}
+
+
+function CountExecs($db, $sql, $inputarray)
+{
+global $EXECS; $EXECS++;
+}
+
+function CountCachedExecs($db, $secs2cache, $sql, $inputarray)
+{
+global $CACHED; $CACHED++;
+}
+
+// the table creation code is specific to the database, so we allow the user
+// to define their own table creation stuff
+
+function testdb(&$db,$createtab="create table ADOXYZ (id int, firstname char(24), lastname char(24), created date)")
+{
+GLOBAL $ADODB_vers,$ADODB_CACHE_DIR,$ADODB_FETCH_MODE,$ADODB_COUNTRECS;
+
+ //adodb_pr($db);
+
+?>
+Close();
+ if ($rs2) $rs2->Close();
+ if ($rs) $rs->Close();
+ $db->Close();
+
+ if ($db->transCnt != 0) Err("Error in transCnt=$db->transCnt (should be 0)");
+
+
+ printf("Total queries=%d; total cached=%d
",$EXECS+$CACHED, $CACHED); + flush(); +} + +function adodb_test_err($dbms, $fn, $errno, $errmsg, $p1=false, $p2=false) +{ +global $TESTERRS,$ERRNO; + + $ERRNO = $errno; + $TESTERRS += 1; + print "** $dbms ($fn): errno=$errno errmsg=$errmsg ($p1,$p2)"; +} +if (sizeof($_GET) == 0) $testmysql = true; + + +foreach($_GET as $k=>$v) { + // XSS protection (see Github issue #274) - only set variables for + // expected get parameters used in testdatabases.inc.php + if(preg_match('/^(test|no)\w+$/', $k)) { + $$k = $v; + } +} + +?> + +
+vers=",ADOConnection::Version(); + + + +?> +
ADODB Database Library (c) 2000-2014 John Lim. All rights reserved. Released under BSD and LGPL, PHP .
+ + diff --git a/vendor/adodb/adodb-php/tests/test2.php b/vendor/adodb/adodb-php/tests/test2.php new file mode 100644 index 00000000..eb3b0258 --- /dev/null +++ b/vendor/adodb/adodb-php/tests/test2.php @@ -0,0 +1,25 @@ +debug=1; + $access = 'd:\inetpub\wwwroot\php\NWIND.MDB'; + $myDSN = 'PROVIDER=Microsoft.Jet.OLEDB.4.0;' + . 'DATA SOURCE=' . $access . ';'; + + echo "PHP ",PHP_VERSION,"
"; + + $db->Connect($myDSN) || die('fail'); + + print_r($db->ServerInfo()); + + try { + $rs = $db->Execute("select $db->sysTimeStamp,* from adoxyz where id>02xx"); + print_r($rs->fields); + } catch(exception $e) { + print_r($e); + echo "Date m/d/Y =",$db->UserDate($rs->fields[4],'m/d/Y'); + } diff --git a/vendor/adodb/adodb-php/tests/test3.php b/vendor/adodb/adodb-php/tests/test3.php new file mode 100644 index 00000000..78c7c775 --- /dev/null +++ b/vendor/adodb/adodb-php/tests/test3.php @@ -0,0 +1,44 @@ +Connect('','scott','natsoft'); +$db->debug=1; + +$cnt = $db->GetOne("select count(*) from adoxyz"); +$rs = $db->Execute("select * from adoxyz order by id"); + +$i = 0; +foreach($rs as $k => $v) { + $i += 1; + echo $k; adodb_pr($v); + flush(); +} + +if ($i != $cnt) die("actual cnt is $i, cnt should be $cnt\n"); + + + +$rs = $db->Execute("select bad from badder"); + +} catch (exception $e) { + adodb_pr($e); + $e = adodb_backtrace($e->trace); +} diff --git a/vendor/adodb/adodb-php/tests/test4.php b/vendor/adodb/adodb-php/tests/test4.php new file mode 100644 index 00000000..7a5d821c --- /dev/null +++ b/vendor/adodb/adodb-php/tests/test4.php @@ -0,0 +1,144 @@ +PConnect("", "sa", "natsoft", "northwind"); // connect to MySQL, testdb + +$conn = ADONewConnection("mysql"); // create a connection +$conn->PConnect("localhost", "root", "", "test"); // connect to MySQL, testdb + + +#$conn = ADONewConnection('oci8po'); +#$conn->Connect('','scott','natsoft'); + +if (PHP_VERSION >= 5) { + $connstr = "mysql:dbname=northwind"; + $u = 'root';$p=''; + $conn = ADONewConnection('pdo'); + $conn->Connect($connstr, $u, $p); +} +//$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; + + +$conn->debug=1; +$conn->Execute("delete from adoxyz where lastname like 'Smi%'"); + +$rs = $conn->Execute($sql); // Execute the query and get the empty recordset +$record = array(); // Initialize an array to hold the record data to insert + +if (strpos($conn->databaseType,'mysql')===false) $record['id'] = 751; +$record["firstname"] = 'Jann'; +$record["lastname"] = "Smitts"; +$record["created"] = time(); + +$insertSQL = $conn->GetInsertSQL($rs, $record); +$conn->Execute($insertSQL); // Insert the record into the database + +if (strpos($conn->databaseType,'mysql')===false) $record['id'] = 752; +// Set the values for the fields in the record +$record["firstname"] = 'anull'; +$record["lastname"] = "Smith\$@//"; +$record["created"] = time(); + +if (isset($_GET['f'])) $ADODB_FORCE_TYPE = $_GET['f']; + +//$record["id"] = -1; + +// Pass the empty recordset and the array containing the data to insert +// into the GetInsertSQL function. The function will process the data and return +// a fully formatted insert sql statement. +$insertSQL = $conn->GetInsertSQL($rs, $record); +$conn->Execute($insertSQL); // Insert the record into the database + + + +$insertSQL2 = $conn->GetInsertSQL($table='ADOXYZ', $record); +if ($insertSQL != $insertSQL2) echo "
Walt's new stuff failed: $insertSQL2
"; +//========================== +// This code tests an update + +$sql = " +SELECT * +FROM ADOXYZ WHERE lastname=".$conn->Param('var'). " ORDER BY 1"; +// Select a record to update + +$varr = array('var'=>$record['lastname'].''); +$rs = $conn->Execute($sql,$varr); // Execute the query and get the existing record to update +if (!$rs || $rs->EOF) print "No record found!
"; + +$record = array(); // Initialize an array to hold the record data to update + + +// Set the values for the fields in the record +$record["firstName"] = "Caroline".rand(); +//$record["lasTname"] = ""; // Update Caroline's lastname from Miranda to Smith +$record["creAted"] = '2002-12-'.(rand()%30+1); +$record['num'] = ''; +// Pass the single record recordset and the array containing the data to update +// into the GetUpdateSQL function. The function will process the data and return +// a fully formatted update sql statement. +// If the data has not changed, no recordset is returned + +$updateSQL = $conn->GetUpdateSQL($rs, $record); +$conn->Execute($updateSQL,$varr); // Update the record in the database +if ($conn->Affected_Rows() != 1)print "Error1 : Rows Affected=".$conn->Affected_Rows().", should be 1
"; + +$record["firstName"] = "Caroline".rand(); +$record["lasTname"] = "Smithy Jones"; // Update Caroline's lastname from Miranda to Smith +$record["creAted"] = '2002-12-'.(rand()%30+1); +$record['num'] = 331; +$updateSQL = $conn->GetUpdateSQL($rs, $record); +$conn->Execute($updateSQL,$varr); // Update the record in the database +if ($conn->Affected_Rows() != 1)print "Error 2: Rows Affected=".$conn->Affected_Rows().", should be 1
"; + +$rs = $conn->Execute("select * from ADOXYZ where lastname like 'Sm%'"); +//adodb_pr($rs); +rs2html($rs); + +$record["firstName"] = "Carol-new-".rand(); +$record["lasTname"] = "Smithy"; // Update Caroline's lastname from Miranda to Smith +$record["creAted"] = '2002-12-'.(rand()%30+1); +$record['num'] = 331; + +$conn->AutoExecute('ADOXYZ',$record,'UPDATE', "lastname like 'Sm%'"); +$rs = $conn->Execute("select * from ADOXYZ where lastname like 'Sm%'"); +//adodb_pr($rs); +rs2html($rs); +} + + +testsql(); diff --git a/vendor/adodb/adodb-php/tests/test5.php b/vendor/adodb/adodb-php/tests/test5.php new file mode 100644 index 00000000..e46bbc1d --- /dev/null +++ b/vendor/adodb/adodb-php/tests/test5.php @@ -0,0 +1,48 @@ +debug=1; + $conn->PConnect("localhost","root","","xphplens"); + print $conn->databaseType.':'.$conn->GenID().'| + |
";
+while( !$rs->EOF ) {
+ $output[] = $rs->fields;
+ var_dump($rs->fields);
+ $rs->MoveNext();
+ print "";
+}
+die();
+
+
+$p = $conn->Prepare('insert into products (productname,unitprice,dcreated) values (?,?,?)');
+echo "
";
+print_r($p);
+
+$conn->debug=1;
+$conn->Execute($p,array('John'.rand(),33.3,$conn->DBDate(time())));
+
+$p = $conn->Prepare('select * from products where productname like ?');
+$arr = $conn->getarray($p,array('V%'));
+print_r($arr);
+die();
+
+//$conn = ADONewConnection("mssql");
+//$conn->Connect('mangrove','sa','natsoft','ai');
+
+//$conn->Connect('mangrove','sa','natsoft','ai');
+$conn->debug=1;
+$conn->Execute('delete from blobtest');
+
+$conn->Execute('insert into blobtest (id) values(1)');
+$conn->UpdateBlobFile('blobtest','b1','../cute_icons_for_site/adodb.gif','id=1');
+$rs = $conn->Execute('select b1 from blobtest where id=1');
+
+$output = "c:\\temp\\test_out-".date('H-i-s').".gif";
+print "Saving file $output, size=".strlen($rs->fields[0])."";
+$fd = fopen($output, "wb");
+fwrite($fd, $rs->fields[0]);
+fclose($fd);
+
+print " View Image";
+//$rs = $conn->Execute('SELECT id,SUBSTRING(b1, 1, 10) FROM blobtest');
+//rs2html($rs);
diff --git a/vendor/adodb/adodb-php/tests/testoci8.php b/vendor/adodb/adodb-php/tests/testoci8.php
new file mode 100644
index 00000000..5eadc22e
--- /dev/null
+++ b/vendor/adodb/adodb-php/tests/testoci8.php
@@ -0,0 +1,84 @@
+
+
+PConnect('','scott','natsoft');
+ if (!empty($testblob)) {
+ $varHoldingBlob = 'ABC DEF GEF John TEST';
+ $num = time()%10240;
+ // create table atable (id integer, ablob blob);
+ $db->Execute('insert into ATABLE (id,ablob) values('.$num.',empty_blob())');
+ $db->UpdateBlob('ATABLE', 'ablob', $varHoldingBlob, 'id='.$num, 'BLOB');
+
+ $rs = $db->Execute('select * from atable');
+
+ if (!$rs) die("Empty RS");
+ if ($rs->EOF) die("EOF RS");
+ rs2html($rs);
+ }
+ $stmt = $db->Prepare('select * from adoxyz where id=?');
+ for ($i = 1; $i <= 10; $i++) {
+ $rs = $db->Execute(
+ $stmt,
+ array($i));
+
+ if (!$rs) die("Empty RS");
+ if ($rs->EOF) die("EOF RS");
+ rs2html($rs);
+ }
+}
+if (1) {
+ $db = ADONewConnection('oci8');
+ $db->PConnect('','scott','natsoft');
+ $db->debug = true;
+ $db->Execute("delete from emp where ename='John'");
+ print $db->Affected_Rows().'
';
+ $stmt = $db->Prepare('insert into emp (empno, ename) values (:empno, :ename)');
+ $rs = $db->Execute($stmt,array('empno'=>4321,'ename'=>'John'));
+ // prepare not quite ready for prime time
+ //$rs = $db->Execute($stmt,array('empno'=>3775,'ename'=>'John'));
+ if (!$rs) die("Empty RS");
+
+ $db->setfetchmode(ADODB_FETCH_NUM);
+
+ $vv = 'A%';
+ $stmt = $db->PrepareSP("BEGIN adodb.open_tab2(:rs,:tt); END;",true);
+ $db->OutParameter($stmt, $cur, 'rs', -1, OCI_B_CURSOR);
+ $db->OutParameter($stmt, $vv, 'tt');
+ $rs = $db->Execute($stmt);
+ while (!$rs->EOF) {
+ adodb_pr($rs->fields);
+ $rs->MoveNext();
+ }
+ echo " val = $vv";
+
+}
+
+if (0) {
+ $db = ADONewConnection('odbc_oracle');
+ if (!$db->PConnect('local_oracle','scott','tiger')) die('fail connect');
+ $db->debug = true;
+ $rs = $db->Execute(
+ 'select * from adoxyz where firstname=? and trim(lastname)=?',
+ array('first'=>'Caroline','last'=>'Miranda'));
+ if (!$rs) die("Empty RS");
+ if ($rs->EOF) die("EOF RS");
+ rs2html($rs);
+}
diff --git a/vendor/adodb/adodb-php/tests/testoci8cursor.php b/vendor/adodb/adodb-php/tests/testoci8cursor.php
new file mode 100644
index 00000000..1f7b381e
--- /dev/null
+++ b/vendor/adodb/adodb-php/tests/testoci8cursor.php
@@ -0,0 +1,110 @@
+PConnect('','scott','natsoft');
+ $db->debug = 99;
+
+
+/*
+*/
+
+ define('MYNUM',5);
+
+
+ $rs = $db->ExecuteCursor("BEGIN adodb.open_tab(:RS,'A%'); END;");
+
+ 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;');
+ $db->OutParameter($stid, $myov, 'myov');
+ $db->Execute($stid);
+ if ($myov != MYNUM) print "Error with myproc
";
+
+
+ $stmt = $db->PrepareSP("BEGIN adodb.data_out(:a1, :a2); END;",true);
+ $a1 = 'Malaysia';
+ //$a2 = ''; # a2 doesn't even need to be defined!
+ $db->InParameter($stmt,$a1,'a1');
+ $db->OutParameter($stmt,$a2,'a2');
+ $rs = $db->Execute($stmt);
+ if ($rs) {
+ if ($a2 !== 'Cinta Hati Malaysia') print "Stored Procedure Error: a2 = $a2";
+ else echo "OK: a2=$a2
";
+ } else {
+ print "Error in using Stored Procedure IN/Out Variables
";
+ }
+
+
+ $tname = 'A%';
+
+ $stmt = $db->PrepareSP('select * from tab where tname like :tablename');
+ $db->Parameter($stmt,$tname,'tablename');
+ $rs = $db->Execute($stmt);
+ rs2html($rs);
diff --git a/vendor/adodb/adodb-php/tests/testpaging.php b/vendor/adodb/adodb-php/tests/testpaging.php
new file mode 100644
index 00000000..947641be
--- /dev/null
+++ b/vendor/adodb/adodb-php/tests/testpaging.php
@@ -0,0 +1,87 @@
+PConnect('localhost','tester','test','test');
+}
+
+if ($driver == 'access') {
+ $db = NewADOConnection('access');
+ $db->PConnect("nwind", "", "", "");
+}
+
+if ($driver == 'ibase') {
+ $db = NewADOConnection('ibase');
+ $db->PConnect("localhost:e:\\firebird\\examples\\employee.gdb", "sysdba", "masterkey", "");
+ $sql = 'select distinct firstname, lastname from adoxyz order by firstname';
+
+}
+if ($driver == 'mssql') {
+ $db = NewADOConnection('mssql');
+ $db->Connect('JAGUAR\vsdotnet','adodb','natsoft','northwind');
+}
+if ($driver == 'oci8') {
+ $db = NewADOConnection('oci8');
+ $db->Connect('','scott','natsoft');
+
+$sql = "select * from (select ID, firstname as \"First Name\", lastname as \"Last Name\" from adoxyz
+ order by 1)";
+}
+
+if ($driver == 'access') {
+ $db = NewADOConnection('access');
+ $db->Connect('nwind');
+}
+
+if (empty($driver) or $driver == 'mysql') {
+ $db = NewADOConnection('mysql');
+ $db->Connect('localhost','root','','test');
+}
+
+//$db->pageExecuteCountRows = false;
+
+$db->debug = true;
+
+if (0) {
+$rs = $db->Execute($sql);
+include_once('../toexport.inc.php');
+print "
";
+print rs2csv($rs); # return a string
+
+print '
';
+$rs->MoveFirst(); # note, some databases do not support MoveFirst
+print rs2tab($rs); # return a string
+
+print '
';
+$rs->MoveFirst();
+rs2tabout($rs); # send to stdout directly
+print "
";
+}
+
+$pager = new ADODB_Pager($db,$sql);
+$pager->showPageLinks = true;
+$pager->linksPerPage = 10;
+$pager->cache = 60;
+$pager->Render($rows=7);
diff --git a/vendor/adodb/adodb-php/tests/testpear.php b/vendor/adodb/adodb-php/tests/testpear.php
new file mode 100644
index 00000000..a59f5f2c
--- /dev/null
+++ b/vendor/adodb/adodb-php/tests/testpear.php
@@ -0,0 +1,35 @@
+setFetchMode(ADODB_FETCH_ASSOC);
+$rs = $db->Query('select firstname,lastname from adoxyz');
+$cnt = 0;
+while ($arr = $rs->FetchRow()) {
+ print_r($arr);
+ print "
";
+ $cnt += 1;
+}
+
+if ($cnt != 50) print "Error in \$cnt = $cnt";
diff --git a/vendor/adodb/adodb-php/tests/testsessions.php b/vendor/adodb/adodb-php/tests/testsessions.php
new file mode 100644
index 00000000..79a66191
--- /dev/null
+++ b/vendor/adodb/adodb-php/tests/testsessions.php
@@ -0,0 +1,100 @@
+Notify Expiring=$ref, sessionkey=$key";
+}
+
+//-------------------------------------------------------------------
+
+error_reporting(E_ALL);
+
+
+ob_start();
+include('../session/adodb-cryptsession2.php');
+
+
+$options['debug'] = 1;
+$db = 'postgres';
+
+#### CONNECTION
+switch($db) {
+case 'oci8':
+ $options['table'] = 'adodb_sessions2';
+ ADOdb_Session::config('oci8', 'mobydick', 'jdev', 'natsoft', 'mobydick',$options);
+ break;
+
+case 'postgres':
+ $options['table'] = 'sessions2';
+ ADOdb_Session::config('postgres', 'localhost', 'postgres', 'natsoft', 'northwind',$options);
+ break;
+
+case 'mysql':
+default:
+ $options['table'] = 'sessions2';
+ ADOdb_Session::config('mysql', 'localhost', 'root', '', 'xphplens_2',$options);
+ break;
+
+
+}
+
+
+
+#### SETUP NOTIFICATION
+ $USER = 'JLIM'.rand();
+ $ADODB_SESSION_EXPIRE_NOTIFY = array('USER','NotifyExpire');
+
+ adodb_session_create_table();
+ session_start();
+
+ adodb_session_regenerate_id();
+
+### SETUP SESSION VARIABLES
+ if (empty($_SESSION['MONKEY'])) $_SESSION['MONKEY'] = array(1,'abc',44.41);
+ else $_SESSION['MONKEY'][0] += 1;
+ if (!isset($_GET['nochange'])) @$_SESSION['AVAR'] += 1;
+
+
+### START DISPLAY
+ print "PHP ".PHP_VERSION."
";
+ print "\$_SESSION['AVAR']={$_SESSION['AVAR']}
";
+
+ print "
Cookies: ";
+ print_r($_COOKIE);
+
+ var_dump($_SESSION['MONKEY']);
+
+### RANDOMLY PERFORM Garbage Collection
+### In real-production environment, this is done for you
+### by php's session extension, which calls adodb_sess_gc()
+### automatically for you. See php.ini's
+### session.cookie_lifetime and session.gc_probability
+
+ if (rand() % 5 == 0) {
+
+ print "
Garbage Collection
";
+ adodb_sess_gc(10);
+
+ if (rand() % 2 == 0) {
+ print "Random own session destroy
";
+ session_destroy();
+ }
+ } else {
+ $DB = ADODB_Session::_conn();
+ $sessk = $DB->qstr('%AZ'.rand().time());
+ $olddate = $DB->DBTimeStamp(time()-30*24*3600);
+ $rr = $DB->qstr(rand());
+ $DB->Execute("insert into {$options['table']} (sesskey,expiry,expireref,sessdata,created,modified) values ($sessk,$olddate, $rr,'',$olddate,$olddate)");
+ }
diff --git a/vendor/adodb/adodb-php/tests/time.php b/vendor/adodb/adodb-php/tests/time.php
new file mode 100644
index 00000000..8261e1e9
--- /dev/null
+++ b/vendor/adodb/adodb-php/tests/time.php
@@ -0,0 +1,16 @@
+
+" );
+echo( "Converted: $convertedDate" ); //why is string returned as one day (3 not 4) less for this example??
diff --git a/vendor/adodb/adodb-php/tests/tmssql.php b/vendor/adodb/adodb-php/tests/tmssql.php
new file mode 100644
index 00000000..0f81311a
--- /dev/null
+++ b/vendor/adodb/adodb-php/tests/tmssql.php
@@ -0,0 +1,79 @@
+mssql";
+ $db = mssql_connect('JAGUAR\vsdotnet','adodb','natsoft') or die('No Connection');
+ mssql_select_db('northwind',$db);
+
+ $rs = mssql_query('select getdate() as date',$db);
+ $o = mssql_fetch_row($rs);
+ print_r($o);
+ mssql_free_result($rs);
+
+ print "Delete
"; flush();
+ $rs2 = mssql_query('delete from adoxyz',$db);
+ $p = mssql_num_rows($rs2);
+ mssql_free_result($rs2);
+
+}
+
+function tpear()
+{
+include_once('DB.php');
+
+ print "PEAR
";
+ $username = 'adodb';
+ $password = 'natsoft';
+ $hostname = 'JAGUAR\vsdotnet';
+ $databasename = 'northwind';
+
+ $dsn = "mssql://$username:$password@$hostname/$databasename";
+ $conn = DB::connect($dsn);
+ print "date=".$conn->GetOne('select getdate()')."
";
+ @$conn->query('create table tester (id integer)');
+ print "Delete
"; flush();
+ $rs = $conn->query('delete from tester');
+ print "date=".$conn->GetOne('select getdate()')."
";
+}
+
+function tadodb()
+{
+include_once('../adodb.inc.php');
+
+ print "ADOdb
";
+ $conn = NewADOConnection('mssql');
+ $conn->Connect('JAGUAR\vsdotnet','adodb','natsoft','northwind');
+// $conn->debug=1;
+ print "date=".$conn->GetOne('select getdate()')."
";
+ $conn->Execute('create table tester (id integer)');
+ print "Delete
"; flush();
+ $rs = $conn->Execute('delete from tester');
+ print "date=".$conn->GetOne('select getdate()')."
";
+}
+
+
+$ACCEPTIP = '127.0.0.1';
+
+$remote = $_SERVER["REMOTE_ADDR"];
+
+if (!empty($ACCEPTIP))
+ if ($remote != '127.0.0.1' && $remote != $ACCEPTIP)
+ die("Unauthorised client: '$remote'");
+
+?>
+mssql
+pear
+adodb
+
+
+
+
+
+
+
+
+
+
+
+
+
+ id
+
+
+ id
+
+
+
+
+
+ SQL to be executed only on specific platforms
+
+ insert into mytable ( row1, row2 ) values ( 12, 'postgres stuff' )
+
+
+ insert into mytable ( row1, row2 ) values ( 12, 'mysql stuff' )
+
+
+ INSERT into simple_table ( name, description ) values ( '12', 'Microsoft stuff' )
+
+
+
\ No newline at end of file
diff --git a/vendor/adodb/adodb-php/tests/xmlschema.xml b/vendor/adodb/adodb-php/tests/xmlschema.xml
new file mode 100644
index 00000000..ea48ae2b
--- /dev/null
+++ b/vendor/adodb/adodb-php/tests/xmlschema.xml
@@ -0,0 +1,33 @@
+
+
+
+
+ An integer row that's a primary key and autoincrements
+
+
+
+
+ A 16 character varchar row that can't be null
+
+
+
+ row1
+ row2
+
+
+
+ SQL to be executed only on specific platforms
+
+ insert into mytable ( row1, row2 ) values ( 12, 'postgres stuff' )
+
+
+ insert into mytable ( row1, row2 ) values ( 12, 'mysql stuff' )
+
+
+ insert into mytable ( row1, row2 ) values ( 12, 'Microsoft stuff' )
+
+
+
+
+
+
\ No newline at end of file
diff --git a/e_lib/adodb5/toexport.inc.php b/vendor/adodb/adodb-php/toexport.inc.php
similarity index 100%
rename from e_lib/adodb5/toexport.inc.php
rename to vendor/adodb/adodb-php/toexport.inc.php
diff --git a/e_lib/adodb5/tohtml.inc.php b/vendor/adodb/adodb-php/tohtml.inc.php
similarity index 100%
rename from e_lib/adodb5/tohtml.inc.php
rename to vendor/adodb/adodb-php/tohtml.inc.php
diff --git a/e_lib/adodb5/xmlschema.dtd b/vendor/adodb/adodb-php/xmlschema.dtd
similarity index 100%
rename from e_lib/adodb5/xmlschema.dtd
rename to vendor/adodb/adodb-php/xmlschema.dtd
diff --git a/e_lib/adodb5/xmlschema03.dtd b/vendor/adodb/adodb-php/xmlschema03.dtd
similarity index 100%
rename from e_lib/adodb5/xmlschema03.dtd
rename to vendor/adodb/adodb-php/xmlschema03.dtd
diff --git a/e_lib/adodb5/xsl/convert-0.1-0.2.xsl b/vendor/adodb/adodb-php/xsl/convert-0.1-0.2.xsl
similarity index 100%
rename from e_lib/adodb5/xsl/convert-0.1-0.2.xsl
rename to vendor/adodb/adodb-php/xsl/convert-0.1-0.2.xsl
diff --git a/e_lib/adodb5/xsl/convert-0.1-0.3.xsl b/vendor/adodb/adodb-php/xsl/convert-0.1-0.3.xsl
similarity index 100%
rename from e_lib/adodb5/xsl/convert-0.1-0.3.xsl
rename to vendor/adodb/adodb-php/xsl/convert-0.1-0.3.xsl
diff --git a/e_lib/adodb5/xsl/convert-0.2-0.1.xsl b/vendor/adodb/adodb-php/xsl/convert-0.2-0.1.xsl
similarity index 100%
rename from e_lib/adodb5/xsl/convert-0.2-0.1.xsl
rename to vendor/adodb/adodb-php/xsl/convert-0.2-0.1.xsl
diff --git a/e_lib/adodb5/xsl/convert-0.2-0.3.xsl b/vendor/adodb/adodb-php/xsl/convert-0.2-0.3.xsl
similarity index 100%
rename from e_lib/adodb5/xsl/convert-0.2-0.3.xsl
rename to vendor/adodb/adodb-php/xsl/convert-0.2-0.3.xsl
diff --git a/e_lib/adodb5/xsl/remove-0.2.xsl b/vendor/adodb/adodb-php/xsl/remove-0.2.xsl
similarity index 100%
rename from e_lib/adodb5/xsl/remove-0.2.xsl
rename to vendor/adodb/adodb-php/xsl/remove-0.2.xsl
diff --git a/e_lib/adodb5/xsl/remove-0.3.xsl b/vendor/adodb/adodb-php/xsl/remove-0.3.xsl
similarity index 100%
rename from e_lib/adodb5/xsl/remove-0.3.xsl
rename to vendor/adodb/adodb-php/xsl/remove-0.3.xsl
diff --git a/vendor/composer/autoload_files.php b/vendor/composer/autoload_files.php
index dd37d858..9fcb4a5f 100644
--- a/vendor/composer/autoload_files.php
+++ b/vendor/composer/autoload_files.php
@@ -8,5 +8,6 @@ $baseDir = dirname($vendorDir);
return array(
'c964ee0ededf28c96ebd9db5099ef910' => $vendorDir . '/guzzlehttp/promises/src/functions_include.php',
'a0edc8309cc5e1d60e3047b5df6b7052' => $vendorDir . '/guzzlehttp/psr7/src/functions_include.php',
+ 'bf9f5270ae66ac6fa0290b4bf47867b7' => $vendorDir . '/adodb/adodb-php/adodb.inc.php',
'37a3dc5111fe8f707ab4c132ef1dbc62' => $vendorDir . '/guzzlehttp/guzzle/src/functions_include.php',
);
diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php
index 87bea681..36f7cc27 100644
--- a/vendor/composer/autoload_static.php
+++ b/vendor/composer/autoload_static.php
@@ -9,6 +9,7 @@ class ComposerStaticInit67b09c83b85c3bc0027caefe5bba171a
public static $files = array (
'c964ee0ededf28c96ebd9db5099ef910' => __DIR__ . '/..' . '/guzzlehttp/promises/src/functions_include.php',
'a0edc8309cc5e1d60e3047b5df6b7052' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/functions_include.php',
+ 'bf9f5270ae66ac6fa0290b4bf47867b7' => __DIR__ . '/..' . '/adodb/adodb-php/adodb.inc.php',
'37a3dc5111fe8f707ab4c132ef1dbc62' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/functions_include.php',
);
diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json
index 27488910..358122c1 100644
--- a/vendor/composer/installed.json
+++ b/vendor/composer/installed.json
@@ -1,4 +1,60 @@
[
+ {
+ "name": "adodb/adodb-php",
+ "version": "v5.20.9",
+ "version_normalized": "5.20.9.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/ADOdb/ADOdb.git",
+ "reference": "f601748cca1ccb86dfd427620a1692a70e681075"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/ADOdb/ADOdb/zipball/f601748cca1ccb86dfd427620a1692a70e681075",
+ "reference": "f601748cca1ccb86dfd427620a1692a70e681075",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.2"
+ },
+ "time": "2016-12-21T17:19:42+00:00",
+ "type": "library",
+ "installation-source": "dist",
+ "autoload": {
+ "files": [
+ "adodb.inc.php"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "BSD-3-Clause",
+ "LGPL-2.1"
+ ],
+ "authors": [
+ {
+ "name": "John Lim",
+ "email": "jlim@natsoft.com",
+ "role": "Author"
+ },
+ {
+ "name": "Damien Regad",
+ "role": "Current maintainer"
+ },
+ {
+ "name": "Mark Newnham",
+ "role": "Developer"
+ }
+ ],
+ "description": "ADOdb is a PHP database abstraction layer library",
+ "homepage": "http://adodb.org/",
+ "keywords": [
+ "abstraction",
+ "database",
+ "layer",
+ "library",
+ "php"
+ ]
+ },
{
"name": "brandonwamboldt/utilphp",
"version": "1.1.0",