public function action($m, $type, $args = [])
    {
        if (!is_array($args)) {
            throw new Exception([
                '$args must be an array',
                'args' => $args,
            ]);
        }

        $action = $this->initAction($m, isset($args[0]) ? $args[0] : null);

        $this->applyConditions($m, $action);
        $this->setLimitOrder($m, $action);

        switch ($type) {
            case 'select':

                return $action;

            case 'count':

                return $action->count();

            /* These are not implemented yet
            case 'field':

                $field = is_string($args[0]) ? $m->getField($args[0]) : $args[0];

                return $action->filterField($field->short_name);

            case 'fx':
            case 'fx0':

                return $action->aggregate($field->short_name, $fx);
            */

            default:
                throw new Exception([
                    'Unsupported action mode',
                    'type' => $type,
                ]);
        }
    }
public function action($m, $type, $args = [])
    {
        if (!is_array($args)) {
            throw new Exception([
                '$args must be an array',
                'args' => $args,
            ]);
        }

        $action = $this->initAction($m, isset($args[0]) ? $args[0] : null);

        $this->applyConditions($m, $action);
        $this->setLimitOrder($m, $action);

        switch ($type) {
            case 'select':

                return $action;

            case 'count':

                return $action->count();

            /* These are not implemented yet
            case 'field':

                $field = is_string($args[0]) ? $m->getField($args[0]) : $args[0];

                return $action->filterField($field->short_name);

            case 'fx':
            case 'fx0':

                return $action->aggregate($field->short_name, $fx);
            */

            default:
                throw new Exception([
                    'Unsupported action mode',
                    'type' => $type,
                ]);
        }
    }
public function action ( $ m , $ type , $ args = [ ] ) { if ( ! is_array ( $ args ) ) { throw new Exception ( [ '$args must be an array' , 'args' => $ args , ] ) ; } $ action = $ this -> initAction ( $ m , isset ( $ args [ 0 ] ) ? $ args [ 0 ] : null ) ; $ this -> applyConditions ( $ m , $ action ) ; $ this -> setLimitOrder ( $ m , $ action ) ; switch ( $ type ) { case 'select' : return $ action ; case 'count' : return $ action -> count ( ) ; /* These are not implemented yet
            case 'field':

                $field = is_string($args[0]) ? $m->getField($args[0]) : $args[0];

                return $action->filterField($field->short_name);

            case 'fx':
            case 'fx0':

                return $action->aggregate($field->short_name, $fx);
            */ default : throw new Exception ( [ 'Unsupported action mode' , 'type' => $ type , ] ) ; } }
Various actions possible here, mostly for compatibility with SQLs.

@param Model  $m
@param string $type
@param array  $args

@return mixed
Various actions possible here mostly for compatibility with SQLs .