additional modifications for #15

Dieser Commit ist enthalten in:
o.pinke 2021-06-21 14:43:19 +02:00
Ursprung 603ce348eb
Commit c0909ffb2d
1 geänderte Dateien mit 19 neuen und 3 gelöschten Zeilen

Datei anzeigen

@ -111,6 +111,12 @@ abstract class ItemCollection extends cItemBaseAbstract {
* @var array Result fields for the query * @var array Result fields for the query
*/ */
protected $_resultFields = array(); protected $_resultFields = array();
/**
*
* @var array Column names of db table
*/
protected $_aTableColums = array();
/** /**
* @var string Encoding * @var string Encoding
@ -624,6 +630,7 @@ abstract class ItemCollection extends cItemBaseAbstract {
$this->_where['groups'] = array(); $this->_where['groups'] = array();
$this->_groupConditions = array(); $this->_groupConditions = array();
$this->_resultFields = array(); $this->_resultFields = array();
$this->_aTableColums = array();
} }
/** /**
@ -708,11 +715,16 @@ abstract class ItemCollection extends cItemBaseAbstract {
* Adds a result field * Adds a result field
* @param string|array $mField * @param string|array $mField
*/ */
public function addResultField($mField) { public function addResultField($mField, $bAll = false) {
if (!is_array($mField)) { if (!empty($mField) && !is_array($mField)) {
$mField = array($mField); $mField = array($mField);
} else if($bAll && empty($this->_aTableColums)) {
$aTemp = $this->db->metadata($this->table);
foreach ($aTemp as $aMeta) {
$this->_aTableColums[] = $aMeta['name'];
}
$mField = $this->_aTableColums;
} }
foreach ($mField as $sField) { foreach ($mField as $sField) {
$sField = strtolower($sField); $sField = strtolower($sField);
if (!in_array($sField, $this->_resultFields)) { if (!in_array($sField, $this->_resultFields)) {
@ -954,6 +966,10 @@ abstract class ItemCollection extends cItemBaseAbstract {
public function fetchTable(array $aFields = array(), array $aObjects = array()) { public function fetchTable(array $aFields = array(), array $aObjects = array()) {
$row = 1; $row = 1;
$aTable = array(); $aTable = array();
if(!empty($this->_aTableColums)) {
$aFields = $this->_aTableColums;
}
if (empty($aFields) && empty($aObjects)) { if (empty($aFields) && empty($aObjects)) {
$aFields = array($this->primaryKey); $aFields = array($this->primaryKey);