/**insert values into a table*/
public abstract function insert($table,array $values);
+ /**update database values*/
+ public abstract function update($table,array $values,$where);
+
/**creates a table; the argument is an array of the form "col-name" => array("col-type", "flags"...); use sqlCreateTable() etc. to create the actual statement*/
protected abstract function createTable($tablename,$table);
return $ret;
}
+ /**creates a SQL92 statement for updates*/
+ protected function sqlUpdate($table,array $values,$where)
+ {
+ global $dbScheme;
+ $ret="UPDATE ".$this->tableName($table)." SET ";
+ reset($values);
+ $cm="";
+ while(list($k,$v)=each($values)){
+ $ret.=$cm;$cm=",";
+ //append column name
+ $ret.=$k."=";
+ //append value
+ if($dbScheme->isIntColumn($table,$k))
+ $val.=$this->escapeInt($v);
+ else
+ if($dbScheme->isStringColumn($table,$k))
+ $val.=$this->escapeString($v);
+ else
+ //don't know how to escape it...
+ $val.="NULL";
+ }
+ $ret.=" WHERE ".$where;
+ return $ret;
+ }
+
/**escapes integers; the default implementation just makes sure it is an int*/
protected function escapeInt($i)
{
return false;
}
+ /**sets a config setting*/
+ public function setConfig($key,$val)
+ {
+ $this->beginTransaction();
+ $mar=$this->select("config","cval","ckey='".addslashes($key)."'");
+ if(count($mar)>0)$this->update("config",array("cval"=>$val),"ckey='".addslashes($key)."'");
+ else $this->insert("config",array("ckey"=>$key,"cval"=>$val));
+ $this->commitTransaction();
+ }
+
/**tries to find out whether the connected DB version is usable*/
public function canUseDb()
{
$p=new Parser("index.html");
$p->setVar("ROLE","buyer");
$list="";
- $temp=$p->getVar("EVENT");;
+ $temp=$p->getVar("EVENT");
//fake1
$p->setVars(array("DATE"=>"heute","PLACE"=>"nirgendwo","EVENTNAME"=>"Hurrah Jazz Club","ARTIST"=>"Broken Blech","PRICE"=>"567,00","ID"=>"1"));
$list.=$p->parse($temp);