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

@ -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";