src/Common/Traits/GetCountCommon.php
protected function getCountCommonCompileSort(array &$aData)
    {
        $oDb = Factory::service('Database');

        if (!empty($aData['sort'])) {

            /**
             * How we handle sorting
             * =====================
             *
             * - If $aData['sort'] is a string assume it's the field to sort on, use the default order
             * - If $aData['sort'] is a single dimension array then assume the first element (or the element
             *   named 'column') is the column; and the second element (or the element named 'order') is the
             *   direction to sort in
             * - If $aData['sort'] is a multidimensional array then loop each element and test as above.
             *
             **/

            if (is_string($aData['sort'])) {

                //  String
                $oDb->order_by($aData['sort']);

            } elseif (is_array($aData['sort'])) {

                $mFirst = reset($aData['sort']);

                if (is_string($mFirst)) {

                    //  Single dimension array
                    $aSort = $this->getCountCommonParseSort($aData['sort']);

                    if (!empty($aSort['column'])) {
                        $oDb->order_by($aSort['column'], $aSort['order']);
                    }

                } else {

                    //  Multi dimension array
                    foreach ($aData['sort'] as $sort) {

                        $aSort = $this->getCountCommonParseSort($sort);

                        if (!empty($aSort['column'])) {
                            $oDb->order_by($aSort['column'], $aSort['order']);
                        }
                    }
                }
            }

        }
    }
protected function getCountCommonCompileSort(array &$aData)
    {
        $oDb = Factory::service('Database');

        if (!empty($aData['sort'])) {

            /**
             * How we handle sorting
             * =====================
             *
             * - If $aData['sort'] is a string assume it's the field to sort on, use the default order
             * - If $aData['sort'] is a single dimension array then assume the first element (or the element
             *   named 'column') is the column; and the second element (or the element named 'order') is the
             *   direction to sort in
             * - If $aData['sort'] is a multidimensional array then loop each element and test as above.
             *
             **/

            if (is_string($aData['sort'])) {

                //  String
                $oDb->order_by($aData['sort']);

            } elseif (is_array($aData['sort'])) {

                $mFirst = reset($aData['sort']);

                if (is_string($mFirst)) {

                    //  Single dimension array
                    $aSort = $this->getCountCommonParseSort($aData['sort']);

                    if (!empty($aSort['column'])) {
                        $oDb->order_by($aSort['column'], $aSort['order']);
                    }

                } else {

                    //  Multi dimension array
                    foreach ($aData['sort'] as $sort) {

                        $aSort = $this->getCountCommonParseSort($sort);

                        if (!empty($aSort['column'])) {
                            $oDb->order_by($aSort['column'], $aSort['order']);
                        }
                    }
                }
            }

        }
    }
protected function getCountCommonCompileSort ( array & $ aData ) { $ oDb = Factory :: service ( 'Database' ) ; if ( ! empty ( $ aData [ 'sort' ] ) ) { /**
             * How we handle sorting
             * =====================
             *
             * - If $aData['sort'] is a string assume it's the field to sort on, use the default order
             * - If $aData['sort'] is a single dimension array then assume the first element (or the element
             *   named 'column') is the column; and the second element (or the element named 'order') is the
             *   direction to sort in
             * - If $aData['sort'] is a multidimensional array then loop each element and test as above.
             *
             **/ if ( is_string ( $ aData [ 'sort' ] ) ) { //  String $ oDb -> order_by ( $ aData [ 'sort' ] ) ; } elseif ( is_array ( $ aData [ 'sort' ] ) ) { $ mFirst = reset ( $ aData [ 'sort' ] ) ; if ( is_string ( $ mFirst ) ) { //  Single dimension array $ aSort = $ this -> getCountCommonParseSort ( $ aData [ 'sort' ] ) ; if ( ! empty ( $ aSort [ 'column' ] ) ) { $ oDb -> order_by ( $ aSort [ 'column' ] , $ aSort [ 'order' ] ) ; } } else { //  Multi dimension array foreach ( $ aData [ 'sort' ] as $ sort ) { $ aSort = $ this -> getCountCommonParseSort ( $ sort ) ; if ( ! empty ( $ aSort [ 'column' ] ) ) { $ oDb -> order_by ( $ aSort [ 'column' ] , $ aSort [ 'order' ] ) ; } } } } } }
Compiles the sort element into the query

@param array &$aData The data array

@return void
Compiles the sort element into the query