src/Common/Model/Base.php
public function getAllFlat($iPage = null, $iPerPage = null, array $aData = [], $bIncludeDeleted = false)
    {
        $aItems = $this->getAll($iPage, $iPerPage, $aData, $bIncludeDeleted);
        $aOut   = [];

        //  Nothing returned? Skip the rest of this method, it's pointless.
        if (!$aItems) {
            return [];
        }

        // --------------------------------------------------------------------------

        //  Test columns
        $oTest = reset($aItems);

        if (!property_exists($oTest, $this->tableLabelColumn)) {
            throw new ModelException(
                static::class . '::getAllFlat() "' . $this->tableLabelColumn . '" is not a valid column.',
                1
            );
        }

        if (!property_exists($oTest, $this->tableLabelColumn)) {
            throw new ModelException(
                static::class . '::getAllFlat() "' . $this->tableIdColumn . '" is not a valid column.',
                1
            );
        }

        unset($oTest);

        // --------------------------------------------------------------------------

        foreach ($aItems as $oItem) {
            $aOut[$oItem->{$this->tableIdColumn}] = $oItem->{$this->tableLabelColumn};
        }

        return $aOut;
    }
public function getAllFlat($iPage = null, $iPerPage = null, array $aData = [], $bIncludeDeleted = false)
    {
        $aItems = $this->getAll($iPage, $iPerPage, $aData, $bIncludeDeleted);
        $aOut   = [];

        //  Nothing returned? Skip the rest of this method, it's pointless.
        if (!$aItems) {
            return [];
        }

        // --------------------------------------------------------------------------

        //  Test columns
        $oTest = reset($aItems);

        if (!property_exists($oTest, $this->tableLabelColumn)) {
            throw new ModelException(
                static::class . '::getAllFlat() "' . $this->tableLabelColumn . '" is not a valid column.',
                1
            );
        }

        if (!property_exists($oTest, $this->tableLabelColumn)) {
            throw new ModelException(
                static::class . '::getAllFlat() "' . $this->tableIdColumn . '" is not a valid column.',
                1
            );
        }

        unset($oTest);

        // --------------------------------------------------------------------------

        foreach ($aItems as $oItem) {
            $aOut[$oItem->{$this->tableIdColumn}] = $oItem->{$this->tableLabelColumn};
        }

        return $aOut;
    }
public function getAllFlat ( $ iPage = null , $ iPerPage = null , array $ aData = [ ] , $ bIncludeDeleted = false ) { $ aItems = $ this -> getAll ( $ iPage , $ iPerPage , $ aData , $ bIncludeDeleted ) ; $ aOut = [ ] ; //  Nothing returned? Skip the rest of this method, it's pointless. if ( ! $ aItems ) { return [ ] ; } // -------------------------------------------------------------------------- //  Test columns $ oTest = reset ( $ aItems ) ; if ( ! property_exists ( $ oTest , $ this -> tableLabelColumn ) ) { throw new ModelException ( static :: class . '::getAllFlat() "' . $ this -> tableLabelColumn . '" is not a valid column.' , 1 ) ; } if ( ! property_exists ( $ oTest , $ this -> tableLabelColumn ) ) { throw new ModelException ( static :: class . '::getAllFlat() "' . $ this -> tableIdColumn . '" is not a valid column.' , 1 ) ; } unset ( $ oTest ) ; // -------------------------------------------------------------------------- foreach ( $ aItems as $ oItem ) { $ aOut [ $ oItem -> { $ this -> tableIdColumn } ] = $ oItem -> { $ this -> tableLabelColumn } ; } return $ aOut ; }
Fetches all objects as a flat array

@param int|null $iPage           The page number of the results
@param int|null $iPerPage        The number of items per page
@param array    $aData           Any data to pass to getCountCommon()
@param bool     $bIncludeDeleted Whether or not to include deleted items

@return array
@throws ModelException
Fetches all objects as a flat array