various minor corrections of sql statements

improves compatibility with postgres
This commit is contained in:
Uwe Steinmann 2019-03-14 09:37:21 +01:00
parent a2fbb7cca0
commit fd5bfe246f

View File

@ -2920,7 +2920,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
$timeline = array(); $timeline = array();
$lc=$this->getLatestContent(); $lc=$this->getLatestContent();
$queryStr = "SELECT `revisiondate`, `version` FROM `tblDocumentContent` WHERE `document` = " . $this->_id . " AND `version` = " . $lc->getVersion(); $queryStr = "SELECT `revisiondate`, `version` FROM `tblDocumentContent` WHERE `document` = " . $this->_id . " AND `version` = " . $lc->getVersion();
$resArr = $db->getResultArray($queryStr); $resArr = $db->getResultArray($queryStr);
if (is_bool($resArr) && $resArr == false) if (is_bool($resArr) && $resArr == false)
return false; return false;
@ -3325,9 +3325,11 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
* *
* @return array latest record from tblDocumentStatusLog * @return array latest record from tblDocumentStatusLog
*/ */
function getStatus() { /* {{{ */ function getStatus($limit=1) { /* {{{ */
$db = $this->_document->_dms->getDB(); $db = $this->_document->_dms->getDB();
if (!is_numeric($limit)) return false;
// Retrieve the current overall status of the content represented by // Retrieve the current overall status of the content represented by
// this object. // this object.
if (!isset($this->_status)) { if (!isset($this->_status)) {
@ -3339,7 +3341,7 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
"LEFT JOIN `tblDocumentStatusLog` USING (`statusID`) ". "LEFT JOIN `tblDocumentStatusLog` USING (`statusID`) ".
"WHERE `tblDocumentStatus`.`documentID` = '". $this->_document->getID() ."' ". "WHERE `tblDocumentStatus`.`documentID` = '". $this->_document->getID() ."' ".
"AND `tblDocumentStatus`.`version` = '". $this->_version ."' ". "AND `tblDocumentStatus`.`version` = '". $this->_version ."' ".
"ORDER BY `tblDocumentStatusLog`.`statusLogID` DESC LIMIT 1"; "ORDER BY `tblDocumentStatusLog`.`statusLogID` DESC LIMIT ".(int) $limit;
$res = $db->getResultArray($queryStr); $res = $db->getResultArray($queryStr);
if (is_bool($res) && !$res) if (is_bool($res) && !$res)
@ -5418,7 +5420,7 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
if (!$this->_workflowState) { if (!$this->_workflowState) {
$queryStr= $queryStr=
"SELECT b.* FROM `tblWorkflowDocumentContent` a LEFT JOIN `tblWorkflowStates` b ON a.`state` = b.`id` WHERE `a`.`id`=". $this->_workflow->getID(); "SELECT b.* FROM `tblWorkflowDocumentContent` a LEFT JOIN `tblWorkflowStates` b ON a.`state` = b.id WHERE `a`.`id`=". $this->_workflow['id'];
$recs = $db->getResultArray($queryStr); $recs = $db->getResultArray($queryStr);
if (is_bool($recs) && !$recs) if (is_bool($recs) && !$recs)
return false; return false;
@ -5482,7 +5484,7 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
if (!isset($this->_workflow)) { if (!isset($this->_workflow)) {
$queryStr= $queryStr=
"SELECT a.`id` as `wdcid`, a.`parent`, b.* FROM `tblWorkflowDocumentContent` a LEFT JOIN `tblWorkflows` b ON a.`workflow` = b.id WHERE a.`version`='".$this->_version "SELECT a.`id` as `wdcid`, a.`parent`, b.* FROM `tblWorkflowDocumentContent` a LEFT JOIN `tblWorkflows` b ON a.`workflow` = b.`id` WHERE a.`version`='".$this->_version
."' AND a.`document` = '". $this->_document->getID() ."' " ."' AND a.`document` = '". $this->_document->getID() ."' "
." AND a.`state` IS NOT NULL" ." AND a.`state` IS NOT NULL"
." ORDER BY `date` DESC LIMIT 1"; ." ORDER BY `date` DESC LIMIT 1";
@ -5974,8 +5976,8 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
* the next state will be reached if one of the transitions * the next state will be reached if one of the transitions
* leading to the given state can be processed. * leading to the given state can be processed.
*/ */
if($nextstate->getPreCondFunc() == '') { if($nextstate->getPreCondFunc() == '') {
$workflow = $this->_workflow['workflow']; $workflow = $this->_workflow['workflow'];
$transitions = $workflow->getPreviousTransitions($nextstate); $transitions = $workflow->getPreviousTransitions($nextstate);
foreach($transitions as $transition) { foreach($transitions as $transition) {
// echo "transition ".$transition->getID()." led to state ".$nextstate->getName()."<br />"; // echo "transition ".$transition->getID()." led to state ".$nextstate->getName()."<br />";