[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnue/phpforms/src database.inc gnue-forms.php
From: |
Jan Ischebeck |
Subject: |
gnue/phpforms/src database.inc gnue-forms.php |
Date: |
Mon, 27 May 2002 14:21:30 -0400 |
CVSROOT: /cvsroot/gnue
Module name: gnue
Changes by: Jan Ischebeck <address@hidden> 02/05/27 14:21:30
Modified files:
phpforms/src : database.inc gnue-forms.php
Log message:
add phpforms entry to global README
fix several bugs in gnue-forms.php and database.inc
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/phpforms/src/database.inc.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/phpforms/src/gnue-forms.php.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
Patches:
Index: gnue/phpforms/src/database.inc
diff -c gnue/phpforms/src/database.inc:1.2 gnue/phpforms/src/database.inc:1.3
*** gnue/phpforms/src/database.inc:1.2 Tue May 7 17:57:05 2002
--- gnue/phpforms/src/database.inc Mon May 27 14:21:30 2002
***************
*** 365,371 ****
$this->datastore=$data["DATASTORE"];
$this->datacount=$data["DATACOUNT"];
}
! function addentry($table,$data) {
$num=$this->datacount[$table];
$this->datastore[$table][$num+1]=$data;
$this->datacount[$table]=$num+1;
--- 365,371 ----
$this->datastore=$data["DATASTORE"];
$this->datacount=$data["DATACOUNT"];
}
! function addEntry($table,$data) {
$num=$this->datacount[$table];
$this->datastore[$table][$num+1]=$data;
$this->datacount[$table]=$num+1;
***************
*** 374,393 ****
if (isset($this->datastore[$table][$index]))
unset($this->datastore[$table][$index]);
}
! function getentry($table,$index) {
if ($index<$this->datacount[$table]) {
$data=$this->datastore[$table][$index];
return $data;
} else return array();
}
! function getEntryIndexList($table,$filter) {
$dataset=$this->datastore[$table];
$index=0;
$indexList=array();
while (list ($key, $value) = each ($dataset)) {
! if (isset($value))
$indexList[$index]=$key;
! }
return $indexList;
}
function addTable($table) {
--- 374,397 ----
if (isset($this->datastore[$table][$index]))
unset($this->datastore[$table][$index]);
}
! function getEntry($table,$index) {
if ($index<$this->datacount[$table]) {
$data=$this->datastore[$table][$index];
return $data;
} else return array();
}
! function getEntryIndexList($table,$filter) {
$dataset=$this->datastore[$table];
$index=0;
$indexList=array();
while (list ($key, $value) = each ($dataset)) {
! if (isset($value)) {
$indexList[$index]=$key;
! DEBUG(5,"Add entry '".$key."' to list (points to value '".
! $value."')");
! }
! $index++;
! };
return $indexList;
}
function addTable($table) {
***************
*** 416,422 ****
var $EntryIndex; // index of entrys
function SessionCacheResultset() {
! DEBUG(3,"New SessionCacheResultset object");
$this->to_delete=array();
$this->changed=array();
$this->filter=array();
--- 420,426 ----
var $EntryIndex; // index of entrys
function SessionCacheResultset() {
! DEBUG(6,"New SessionCacheResultset object");
$this->to_delete=array();
$this->changed=array();
$this->filter=array();
***************
*** 432,448 ****
return true;
}
function markforRemoval($recordno) {
$recordno=$this->EntryIndex[$recordno];
if (isset($recordno)) {
! if ($this->to_delete[$recordno])
! $this->to_delete[$recordno]=true;
! else
unset($this->to_delete[$recordno]);
! }
}
function ismarkedforRemoval ($recordno) {
$recordno=$this->EntryIndex[$recordno];
! if (isset($recordno)) {
return ($this->to_delete[$recordno]==true);
}
}
--- 436,455 ----
return true;
}
function markforRemoval($recordno) {
+ DEBUG(5,"Record No ".$recordno." should be deleted.");
$recordno=$this->EntryIndex[$recordno];
if (isset($recordno)) {
! if ($this->to_delete[$recordno]) {
unset($this->to_delete[$recordno]);
! } else {
! $this->to_delete[$recordno]=true;
! };
! };
!
}
function ismarkedforRemoval ($recordno) {
$recordno=$this->EntryIndex[$recordno];
! if (isset($recordno)) {
return ($this->to_delete[$recordno]==true);
}
}
***************
*** 451,489 ****
}
function commit() { // write datacache
if (!isset($this->dbcon)) return;
! // create a new datacache/status without deleted objects
! $dcnew=array(); $dsnew=array(); $j=0;
! for ($i=0;$i<=$this->lastentry;$i++) {
! if ($this->datastatus[$i]=="N") {
! $oid=$this->dbcon->insert($this->datacache[$i],
! $this->table);
! $this->datacache[$i]["oid"]=$oid;
! $this->datastatus[$i]="";
! };
! if ($this->datastatus[$i]=="C") { // write the changed entrys
! $this->dbcon->change($this->datacache[$i],
! $this->table);
! $this->datastatus[$i]="";
};
- if ($this->datastatus[$i]=="D") {
- $this->dbcon->delete($this->datacache[$i],
- $this->table);
- };
- // dont write new records which are deleted (R)
- // dont write/change unchanged old records ("")
- if ($this->datastatus[$i]=="") {
- // if not deleted write to the new cache
- $dcnew[$j]=$this->datacache[$i];
- $dsnew[$j]="";
- $j++;
- }
}
! $this->datacache=$dcnew;
! $this->datastatus=$dsnew;
! $this->lastentry=count($this->datacache)-1;
! if ($this->lastentry==-1) // a least one entry should be in the
! $this->newEntry(); // Resultset
! }
function newEntry($pos=-1) {
if ($pos==-1) {
$this->lastentry=count($this->EntryIndex);
--- 458,497 ----
}
function commit() { // write datacache
if (!isset($this->dbcon)) return;
! // update session database
! while (list($k,$v)=each($this->changed)) {
! if ($k[0]=='N') {
! // new entry
! if ($this->to_delete[$k]) {
! // if marked to be deleted, just remove mark
! unset($this->to_delete[$k]);
! } else {
! // add entry to db
! $this->dbcon->addentry($this->table,$v);
! }
! } else {
! // old entry, change or delete
! if (!$this->to_delete[$k]) {
! $this->dbcon->deleteEntry($this->table,$k);
! unset($this->to_delete[$k]);
! } else {
! $this->dbcon->datastore[$this->table][$index]=$v;
! }
};
}
! // care for the rest of the 'marked for deletion entries'
! while (list($k,$v)=each($this->to_delete)) {
! $this->dbcon->deleteEntry($this->table,$k);
! }
! $this->to_delete=array();
! $this->changed=array();
! $this->setFilter($this->filter);
! }
! function rollback() {
! $this->to_delete=array();
! $this->changed=array();
! $this->setFilter($this->filter);
! }
function newEntry($pos=-1) {
if ($pos==-1) {
$this->lastentry=count($this->EntryIndex);
***************
*** 525,531 ****
$this->newEntry(); // Resultset
}
function getField($fieldname,$pos) {
! DEBUG(7,"getField($fieldname,$pos)");
$recordno=$this->EntryIndex[$pos];
if (isset($recordno)) {
$ent=$this->changed[$recordno];
--- 533,539 ----
$this->newEntry(); // Resultset
}
function getField($fieldname,$pos) {
! DEBUG(10,"getField($fieldname,$pos)");
$recordno=$this->EntryIndex[$pos];
if (isset($recordno)) {
$ent=$this->changed[$recordno];
***************
*** 536,542 ****
return $ent[$fieldname];
}
function setField($fieldname,$pos,$data) {
! DEBUG(7,"setField($fieldname,$pos,$data)");
$recordno=$this->EntryIndex[$pos];
if (isset($recordno)) {
$ent=$this->changed[$recordno];
--- 544,550 ----
return $ent[$fieldname];
}
function setField($fieldname,$pos,$data) {
! DEBUG(10,"setField($fieldname,$pos,$data)");
$recordno=$this->EntryIndex[$pos];
if (isset($recordno)) {
$ent=$this->changed[$recordno];
Index: gnue/phpforms/src/gnue-forms.php
diff -c gnue/phpforms/src/gnue-forms.php:1.3
gnue/phpforms/src/gnue-forms.php:1.4
*** gnue/phpforms/src/gnue-forms.php:1.3 Tue May 7 17:57:05 2002
--- gnue/phpforms/src/gnue-forms.php Mon May 27 14:21:30 2002
***************
*** 35,50 ****
// code print out
$clientversion="0.0.8.1"; // changes to database/datasource creation code
! $debuglevel=1;
require_once("connection.php");
#require_once("xmlrpc.inc"); // has to be included here to get global scope
function DEBUG($level,$str) {
global $debuglevel;
! if ($level<=$debuglevel)
! print("DEBUG (".$level."):".$str."<BR>");
}
############### FILE UI.PHP ############ BEGIN ###########
--- 35,67 ----
// code print out
$clientversion="0.0.8.1"; // changes to database/datasource creation code
!
! // set debug level
! $debuglevel=9; // > 10 very detailed
! // > 3 normal
! // > 1 just basics
! // 0,1 no debugging messages
require_once("connection.php");
#require_once("xmlrpc.inc"); // has to be included here to get global scope
+ // +++++++++++++ Debugging Code ++++++++++++++++++++++++++++++
+
+ if ($debuglevel>8) {
+ error_log ("\n\n".
+ "****************************************\n".
+ " phpforms restarted \n".
+ "****************************************\n\n",
+ 3, "/tmp/phpforms-errors.log");
+ }
function DEBUG($level,$str) {
global $debuglevel;
! if ($level<=$debuglevel) {
! $estr="DEBUG (".$level."):".$str;
! # print($estr."<BR>");
! error_log ($estr."\n", 3, "/tmp/phpforms-errors.log");
! }
}
############### FILE UI.PHP ############ BEGIN ###########
***************
*** 1063,1082 ****
$bn=$attr["NAME"];
$b->setName($bn);
$b->setAttr($attr);
! $b->setParent($this);
! $dts=&$this->datasources[$attr["DATASOURCE"]];
! if (!isset($dts)) {
// WARNING: NO DATASOURCE DEFINED
// create demo datasource
$attr["DATASOURCE"]="demodatasource_".$attr["NAME"];
$b->setAttr($attr); // dont't forget to update attr
$dts_attr=array("NAME"=>$attr["DATASOURCE"],
"TABLE"=>"fantasie");
$this->addDatasource($dts_attr);
$dts=&$this->datasources[$attr["DATASOURCE"]];
!
! // ATTENTION: IF THE DATASOURCE IS DEFINED BEHIND THE BLOCK
! // IT USES DEMO DATASOURCE AND NO REAL DTS
};
$b->setDatasource(&$dts);
$this->blocks[$bn]=&$b;
--- 1080,1108 ----
$bn=$attr["NAME"];
$b->setName($bn);
$b->setAttr($attr);
! $b->setParent($this);
!
! // check if datasource exists
! if (array_key_exists($attr["DATASOURCE"], $this->datasources)) {
!
! $dts=&$this->datasources[$attr["DATASOURCE"]];
! DEBUG(6,"Using Datasource '".$attr["DATASOURCE"]."' for block '".
! $attr["NAME"]."'");
! } else {
!
// WARNING: NO DATASOURCE DEFINED
// create demo datasource
+
+ // ATTENTION: IF THE DATASOURCE IS DEFINED BEHIND THE BLOCK
+ // IT USES DEMO DATASOURCE AND NO REAL DTS
$attr["DATASOURCE"]="demodatasource_".$attr["NAME"];
$b->setAttr($attr); // dont't forget to update attr
$dts_attr=array("NAME"=>$attr["DATASOURCE"],
"TABLE"=>"fantasie");
$this->addDatasource($dts_attr);
$dts=&$this->datasources[$attr["DATASOURCE"]];
! DEBUG(6,"No Datasource defined!!!");
! DEBUG(6,"Creating a demo datasource (value: ".$dts.")");
};
$b->setDatasource(&$dts);
$this->blocks[$bn]=&$b;
***************
*** 1541,1547 ****
reset($this->datasources);
while (list ($k, $v) = each ($this->datasources)) {
if (strlen($k)>0) {
! DEBUG(3,"SAVED DATASOURCE : $k TYPE : $v <BR>\n");
$dtsdata[$k]=$v->getBackupData();
}
};
--- 1567,1573 ----
reset($this->datasources);
while (list ($k, $v) = each ($this->datasources)) {
if (strlen($k)>0) {
! DEBUG(3,"SAVED DATASOURCE : '$k' TYPE : '$v' ");
$dtsdata[$k]=$v->getBackupData();
}
};
***************
*** 1549,1561 ****
reset($this->pages);
while (list ($k, $v) = each ($this->pages)) {
$pgdata[$k]=$v->getBackupData();
! DEBUG(3,"SAVED PAGE : $k TYPE : $v <BR>\n");
};
$dbdata=array();
reset($this->dbcons);
while (list ($k, $v) = each($this->dbcons)) {
if (strlen($k)>0) {
! DEBUG(3,"forms: SAVED DB : $k TYPE : $v \n");
$dbdata[$k]=$v->getBackupData();
};
};
--- 1575,1587 ----
reset($this->pages);
while (list ($k, $v) = each ($this->pages)) {
$pgdata[$k]=$v->getBackupData();
! DEBUG(3,"SAVED PAGE : '$k' TYPE : '$v' ");
};
$dbdata=array();
reset($this->dbcons);
while (list ($k, $v) = each($this->dbcons)) {
if (strlen($k)>0) {
! DEBUG(3,"forms: SAVED DB : '$k' TYPE : '$v'");
$dbdata[$k]=$v->getBackupData();
};
};
***************
*** 1563,1569 ****
reset($this->blocks);
while (list ($k, $v) = each($this->blocks)) {
$bldata[$k]=$v->getBackupData();
! DEBUG(3,"SAVED BLOCK : $k TYPE : $v <BR>\n");
};
if (isset($this->sel_block))
$blname=$this->sel_block->getName();
--- 1589,1595 ----
reset($this->blocks);
while (list ($k, $v) = each($this->blocks)) {
$bldata[$k]=$v->getBackupData();
! DEBUG(3,"SAVED BLOCK : '$k' TYPE : '$v'");
};
if (isset($this->sel_block))
$blname=$this->sel_block->getName();
***************
*** 1584,1590 ****
if (isset($dbdata)) {
reset($dbdata);
while (list ($k, $v) = each($dbdata)) {
! DEBUG(3,"forms: RESTORE DB : $k TYPE : $v \n");
if (isset($this->dbcons[$k])) {
echo "SESSION RESTORE ERROR";
} else {
--- 1610,1616 ----
if (isset($dbdata)) {
reset($dbdata);
while (list ($k, $v) = each($dbdata)) {
! DEBUG(3,"forms: RESTORE DB : '$k' TYPE : '$v'");
if (isset($this->dbcons[$k])) {
echo "SESSION RESTORE ERROR";
} else {
***************
*** 1598,1604 ****
if (isset($dtsdata)) {
reset($dtsdata);
while (list ($k, $v) = each($dtsdata)) {
! DEBUG(3,"forms: RESTORE DATASOURCE : $k TYPE : $v \n");
if (isset($this->datasources[$k])) {
echo "SESSION RESTORE ERROR";
} else {
--- 1624,1630 ----
if (isset($dtsdata)) {
reset($dtsdata);
while (list ($k, $v) = each($dtsdata)) {
! DEBUG(3,"forms: RESTORE DATASOURCE : '$k' TYPE : '$v'");
if (isset($this->datasources[$k])) {
echo "SESSION RESTORE ERROR";
} else {
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- gnue/phpforms/src database.inc gnue-forms.php,
Jan Ischebeck <=