}
/**return the version of this scheme*/
- public function version(){return $this->sversion;}
+ public function version(){return self::$sversion;}
/**return the tables to be created in order*/
public function tableNames()
{
- return array_keys($this->scheme);
+ return array_keys(self::$scheme);
}
/**returns whether a table exists in the schema*/
public function hasTable($t)
{
- return in_array($t,array_keys($this->scheme));
+ return in_array($t,array_keys(self::$scheme));
}
/**return the tables that are included in the backup*/
public function backupTables()
{
- return $this->backup;
+ return self::$backup;
}
/**return the full definition of a table, or false if it does not exist*/
public function tableDefinition($tab)
{
- if(!isset($this->scheme[$tab]))
+ if(!isset(self::$scheme[$tab]))
return false;
- return $this->scheme[$tab];
+ return self::$scheme[$tab];
}
/**return the names of all columns of a table, or false if the table does not exist*/
public function tableColumns($tab)
{
- if(!isset($this->scheme[$tab]))
+ if(!isset(self::$scheme[$tab]))
return false;
$r=array();
- foreach(array_keys($this->scheme[$tab]) as $c)
+ foreach(array_keys(self::$scheme[$tab]) as $c)
if(substr($c,0,1)!=":")
$r[]=$c;
return $r;
/**return whether the table has this column*/
public function tableHasColumn($tab,$col)
{
- return isset($this->scheme[$tab][$col]);
+ return isset(self::$scheme[$tab][$col]);
}
/**return default lines of the table for the initialization; returns empty array if there are none*/
public function tableDefaults($tab)
{
- if(isset($this->preset[$tab]))return $this->preset[$tab];
+ if(isset(self::$preset[$tab]))return self::$preset[$tab];
else return array();
}
/**return the type of a column, or false if it does not exist*/
public function columnType($tab,$col)
{
- if(!isset($this->scheme[$tab][$col]))
+ if(!isset(self::$scheme[$tab][$col]))
return false;
- return $this->scheme[$tab][$col][0];
+ return self::$scheme[$tab][$col][0];
}
/**return the flags of a column, empty array if no flags are set, or false if the column does not exist*/
public function columnFlags($tab,$col)
{
- if(!isset($this->scheme[$tab][$col]))
+ if(!isset(self::$scheme[$tab][$col]))
return false;
- $tmp=$this->scheme[$tab][$col];
+ $tmp=self::$scheme[$tab][$col];
unset($tmp[0]);
return array_values($tmp);
}
/**returns true if the given column is of an integer type*/
public function isIntColumn($tab,$col)
{
- if(!isset($this->scheme[$tab][$col]))
+ if(!isset(self::$scheme[$tab][$col]))
return false;
- $tpa=explode(":",$this->scheme[$tab][$col][0]);
+ $tpa=explode(":",self::$scheme[$tab][$col][0]);
switch($tpa[0]){
case "int32":case "seq32":case "int64":case "seq64":case "enum":case "enum32":case "enum64":
return true;
/**returns the sequence column name if the table has a sequence, false otherwise*/
public function hasSequence($tab)
{
- if(!isset($this->scheme[$tab]))
+ if(!isset(self::$scheme[$tab]))
return false;
- foreach($this->scheme[$tab] as $cl => $def){
+ foreach(self::$scheme[$tab] as $cl => $def){
if($def[0] == "seq32" || $def[0] == "seq64")
return $cl;
}
/**returns true if the given column is of a string type*/
public function isStringColumn($tab,$col)
{
- if(!isset($this->scheme[$tab][$col]))
+ if(!isset(self::$scheme[$tab][$col]))
return false;
- $tpa=explode(":",$this->scheme[$tab][$col][0]);
+ $tpa=explode(":",self::$scheme[$tab][$col][0]);
switch($tpa[0]){
case "string":case "text":
return true;
/**returns true if the given column is of a blob type*/
public function isBlobColumn($tab,$col)
{
- if(!isset($this->scheme[$tab][$col]))
+ if(!isset(self::$scheme[$tab][$col]))
return false;
- $tpa=explode(":",$this->scheme[$tab][$col][0]);
+ $tpa=explode(":",self::$scheme[$tab][$col][0]);
switch($tpa[0]){
case "blob":
return true;
/**returns true if the given column is of a bool type*/
public function isBoolColumn($tab,$col)
{
- if(!isset($this->scheme[$tab][$col]))
+ if(!isset(self::$scheme[$tab][$col]))
return false;
- $tpa=explode(":",$this->scheme[$tab][$col][0]);
+ $tpa=explode(":",self::$scheme[$tab][$col][0]);
switch($tpa[0]){
case "bool":
case "boolean":
{
$r=array();
//search for direct mark
- foreach($this->scheme[$tab] as $col=>$def)
+ foreach(self::$scheme[$tab] as $col=>$def)
if(in_array("primarykey",$def))
$r[]=$col;
//search for special mark
- if(isset($this->scheme[$tab][":primarykey"]))
- foreach($this->scheme[$tab][":primarykey"] as $col)
+ if(isset(self::$scheme[$tab][":primarykey"]))
+ foreach(self::$scheme[$tab][":primarykey"] as $col)
if(!in_array($col,$r))
$r[]=$col;
//return result
}
m_schema.write(PHPSTART);
m_schema.write(SCHEMASTART);
- m_schema.write(("\t$this->sversion=\""+WocProcessor::instance()->dbVersion()+"\";\n").toAscii());
+ m_schema.write(("\tself::$sversion=\""+WocProcessor::instance()->dbVersion()+"\";\n").toAscii());
addLoad("WobSchema","schema");
//create Transaction file
m_transact.setFileName(m_basedir+"/"+m_subdir+"/transaction"+m_fileext);
//extend schema file
//column definitions
- code="\t$this->scheme[\""+tbl.name()+"\"]=array(";
+ code="\tself::$scheme[\""+tbl.name()+"\"]=array(";
for(int i=0;i<cols.size();i++){
if(i)code+=",";
code+="\n\t\t\""+cols[i]+"\"=>array(\"";
code+=")";
}
code+="\n\t);\n";
- if(tbl.inBackup())code+="\t$this->backup[]=\""+tbl.name()+"\";\n";
+ if(tbl.inBackup())code+="\tself::$backup[]=\""+tbl.name()+"\";\n";
//write presets
QList<QMap<QString,QString> >presets=tbl.presets();
if(presets.size()>0){
- code+="\t$this->preset[\""+tbl.name()+"\"]=array(";
+ code+="\tself::$preset[\""+tbl.name()+"\"]=array(";
for(int i=0;i<presets.size();i++){
if(i)code+=",";
code+="\n\t\tarray(";