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; 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; 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 * @var boolean set to true if in a database transaction
*/ */
@ -157,6 +162,7 @@ class SeedDMS_Core_DatabaseAccess {
$this->_ttstatid = false; $this->_ttstatid = false;
$this->_ttcontentid = false; $this->_ttcontentid = false;
$this->_ttreceiptid = false; $this->_ttreceiptid = false;
$this->_ttrevisionid = false;
$this->_debug = false; $this->_debug = false;
} /* }}} */ } /* }}} */
@ -473,6 +479,39 @@ class SeedDMS_Core_DatabaseAccess {
} }
return $this->_ttreceiptid; 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; return false;
} /* }}} */ } /* }}} */