create temp table for document revisions

This commit is contained in:
Uwe Steinmann 2017-01-25 09:52:16 +01:00
parent 8c63cc607b
commit bbcff75b00

View File

@ -88,10 +88,15 @@ class SeedDMS_Core_DatabaseAccess {
private $_ttcontentid;
/**
* @var boolean set to true if temp. table for doc content has been created
* @var boolean set to true if temp. table for doc reception has been created
*/
private $_ttreceiptid;
/**
* @var boolean set to true if temp. table for doc revision has been created
*/
private $_ttrevisionid;
/**
* @var boolean set to true if in a database transaction
*/
@ -157,6 +162,7 @@ class SeedDMS_Core_DatabaseAccess {
$this->_ttstatid = false;
$this->_ttcontentid = false;
$this->_ttreceiptid = false;
$this->_ttrevisionid = false;
$this->_debug = false;
} /* }}} */
@ -341,7 +347,7 @@ class SeedDMS_Core_DatabaseAccess {
}
return $this->_ttreviewid;
}
else if (!strcasecmp($tableName, "ttapproveid")) {
elseif (!strcasecmp($tableName, "ttapproveid")) {
switch($this->_driver) {
case 'sqlite':
$queryStr = "CREATE TEMPORARY TABLE IF NOT EXISTS `ttapproveid` AS ".
@ -374,7 +380,7 @@ class SeedDMS_Core_DatabaseAccess {
}
return $this->_ttapproveid;
}
else if (!strcasecmp($tableName, "ttstatid")) {
elseif (!strcasecmp($tableName, "ttstatid")) {
switch($this->_driver) {
case 'sqlite':
$queryStr = "CREATE TEMPORARY TABLE IF NOT EXISTS `ttstatid` AS ".
@ -407,7 +413,7 @@ class SeedDMS_Core_DatabaseAccess {
}
return $this->_ttstatid;
}
else if (!strcasecmp($tableName, "ttcontentid")) {
elseif (!strcasecmp($tableName, "ttcontentid")) {
switch($this->_driver) {
case 'sqlite':
$queryStr = "CREATE TEMPORARY TABLE `ttcontentid` AS ".
@ -473,6 +479,39 @@ class SeedDMS_Core_DatabaseAccess {
}
return $this->_ttreceiptid;
}
elseif (!strcasecmp($tableName, "ttrevisionid")) {
switch($this->_driver) {
case 'sqlite':
$queryStr = "CREATE TEMPORARY TABLE IF NOT EXISTS `ttrevisionid` AS ".
"SELECT `tblDocumentRevisionLog`.`revisionID`, ".
"MAX(`tblDocumentRevisionLog`.`revisionLogID`) AS `maxLogID` ".
"FROM `tblDocumentRevisionLog` ".
"GROUP BY `tblDocumentRevisionLog`.`revisionID` ".
"ORDER BY `maxLogID`";
break;
default:
$queryStr = "CREATE TEMPORARY TABLE IF NOT EXISTS `ttrevisionid` (PRIMARY KEY (`revisionID`), INDEX (`maxLogID`)) ".
"SELECT `tblDocumentRevisionLog`.`revisionID`, ".
"MAX(`tblDocumentRevisionLog`.`revisionLogID`) AS `maxLogID` ".
"FROM `tblDocumentRevisionLog` ".
"GROUP BY `tblDocumentRevisionLog`.`revisionID` ".
"ORDER BY `maxLogID`";
}
if (!$this->_ttrevisionid) {
if (!$this->getResult($queryStr))
return false;
$this->_ttrevisionid=true;
}
else {
if (is_bool($override) && $override) {
if (!$this->getResult("DELETE FROM `ttrevisionid`"))
return false;
if (!$this->getResult($queryStr))
return false;
}
}
return $this->_ttrevisionid;
}
return false;
} /* }}} */