diff --git a/SeedDMS_Core/Core/inc.ClassDMS.php b/SeedDMS_Core/Core/inc.ClassDMS.php index 293ccea2e..3988f2b08 100644 --- a/SeedDMS_Core/Core/inc.ClassDMS.php +++ b/SeedDMS_Core/Core/inc.ClassDMS.php @@ -3174,14 +3174,14 @@ class SeedDMS_Core_DMS { function getStatisticalData($type='') { /* {{{ */ switch($type) { case 'docsperuser': - $queryStr = "select concat(b.`fullName`, ' (', b.`login`, ')') as `key`, count(`owner`) as total from `tblDocuments` a left join `tblUsers` b on a.`owner`=b.`id` group by `owner`, b.`fullName`"; + $queryStr = "select ".$this->db->concat(array('b.`fullName`', "' ('", 'b.`login`', "')'"))." as `key`, count(`owner`) as total from `tblDocuments` a left join `tblUsers` b on a.`owner`=b.`id` group by `owner`, b.`fullName`"; $resArr = $this->db->getResultArray($queryStr); if (!$resArr) return false; return $resArr; case 'foldersperuser': - $queryStr = "select concat(b.`fullName`, ' (', b.`login`, ')') as `key`, count(`owner`) as total from `tblFolders` a left join `tblUsers` b on a.`owner`=b.`id` group by `owner`, b.`fullName`"; + $queryStr = "select ".$this->db->concat(array('b.`fullName`', "' ('", 'b.`login`', "')'"))." as `key`, count(`owner`) as total from `tblFolders` a left join `tblUsers` b on a.`owner`=b.`id` group by `owner`, b.`fullName`"; $resArr = $this->db->getResultArray($queryStr); if (!$resArr) return false; diff --git a/SeedDMS_Core/Core/inc.DBAccessPDO.php b/SeedDMS_Core/Core/inc.DBAccessPDO.php index a272fffb9..e48f5f3d5 100644 --- a/SeedDMS_Core/Core/inc.DBAccessPDO.php +++ b/SeedDMS_Core/Core/inc.DBAccessPDO.php @@ -346,6 +346,27 @@ class SeedDMS_Core_DatabaseAccess { return str_replace('`', '"', $text); } /* }}} */ + /** + * Return sql to concat strings or fields + * + * @param array $arr list of field names or strings + * @return string concated string + */ + function concat($arr) { /* {{{ */ + switch($this->_driver) { + case 'mysql': + return 'concat('.implode(',', $arr).')'; + break; + case 'pgsql': + return implode(' || ', $arr); + break; + case 'sqlite': + return implode(' || ', $arr); + break; + } + return ''; + } /* }}} */ + /** * Execute SQL query and return result *