mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-05-11 20:21:16 +00:00
add method concat() and use it in getStatistics() for docspersuser and foldersperuser
This commit is contained in:
parent
51b72eb7b2
commit
39eda2a180
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue
Block a user