create temp table ttreceiptid

This commit is contained in:
Uwe Steinmann 2016-09-28 21:28:51 +02:00
parent 3e777f987d
commit 88d7f252b6

View File

@ -434,6 +434,39 @@ class SeedDMS_Core_DatabaseAccess {
}
return $this->_ttcontentid;
}
elseif (!strcasecmp($tableName, "ttreceiptid")) {
switch($this->_driver) {
case 'sqlite':
$queryStr = "CREATE TEMPORARY TABLE IF NOT EXISTS `ttreceiptid` AS ".
"SELECT `tblDocumentReceiptLog`.`receiptID`, ".
"MAX(`tblDocumentReceiptLog`.`receiptLogID`) AS `maxLogID` ".
"FROM `tblDocumentReceiptLog` ".
"GROUP BY `tblDocumentReceiptLog`.`receiptID` ".
"ORDER BY `maxLogID`";
break;
default:
$queryStr = "CREATE TEMPORARY TABLE IF NOT EXISTS `ttreceiptid` (PRIMARY KEY (`receiptID`), INDEX (`maxLogID`)) ".
"SELECT `tblDocumentReceiptLog`.`receiptID`, ".
"MAX(`tblDocumentReceiptLog`.`receiptLogID`) AS `maxLogID` ".
"FROM `tblDocumentReceiptLog` ".
"GROUP BY `tblDocumentReceiptLog`.`receiptID` ".
"ORDER BY `maxLogID`";
}
if (!$this->_ttreceiptid) {
if (!$this->getResult($queryStr))
return false;
$this->_ttreceiptid=true;
}
else {
if (is_bool($override) && $override) {
if (!$this->getResult("DELETE FROM `ttreceiptid`"))
return false;
if (!$this->getResult($queryStr))
return false;
}
}
return $this->_ttreceiptid;
}
return false;
} /* }}} */