public function initQueryFields($m, $q, $fields = null)
    {
        // do nothing on purpose
        if ($fields === false) {
            return;
        }

        // init fields
        if (is_array($fields)) {

            // Set of fields is strictly defined for purposes of export,
            // so we will ignore even system fields.
            foreach ($fields as $field) {
                $this->initField($q, $m->getField($field));
            }
        } elseif ($m->only_fields) {
            $added_fields = [];

            // Add requested fields first
            foreach ($m->only_fields as $field) {
                $f_object = $m->getField($field);
                if ($f_object->never_persist) {
                    continue;
                }
                $this->initField($q, $f_object);
                $added_fields[$field] = true;
            }

            // now add system fields, if they were not added
            foreach ($m->elements as $field => $f_object) {
                if ($f_object instanceof Field) {
                    if ($f_object->never_persist) {
                        continue;
                    }
                    if ($f_object->system && !isset($added_fields[$field])) {
                        $this->initField($q, $f_object);
                    }
                }
            }
        } else {
            foreach ($m->elements as $field => $f_object) {
                if ($f_object instanceof Field) {
                    if ($f_object->never_persist) {
                        continue;
                    }
                    $this->initField($q, $f_object);
                }
            }
        }
    }
public function initQueryFields($m, $q, $fields = null)
    {
        // do nothing on purpose
        if ($fields === false) {
            return;
        }

        // init fields
        if (is_array($fields)) {

            // Set of fields is strictly defined for purposes of export,
            // so we will ignore even system fields.
            foreach ($fields as $field) {
                $this->initField($q, $m->getField($field));
            }
        } elseif ($m->only_fields) {
            $added_fields = [];

            // Add requested fields first
            foreach ($m->only_fields as $field) {
                $f_object = $m->getField($field);
                if ($f_object->never_persist) {
                    continue;
                }
                $this->initField($q, $f_object);
                $added_fields[$field] = true;
            }

            // now add system fields, if they were not added
            foreach ($m->elements as $field => $f_object) {
                if ($f_object instanceof Field) {
                    if ($f_object->never_persist) {
                        continue;
                    }
                    if ($f_object->system && !isset($added_fields[$field])) {
                        $this->initField($q, $f_object);
                    }
                }
            }
        } else {
            foreach ($m->elements as $field => $f_object) {
                if ($f_object instanceof Field) {
                    if ($f_object->never_persist) {
                        continue;
                    }
                    $this->initField($q, $f_object);
                }
            }
        }
    }
public function initQueryFields ( $ m , $ q , $ fields = null ) { // do nothing on purpose if ( $ fields === false ) { return ; } // init fields if ( is_array ( $ fields ) ) { // Set of fields is strictly defined for purposes of export, // so we will ignore even system fields. foreach ( $ fields as $ field ) { $ this -> initField ( $ q , $ m -> getField ( $ field ) ) ; } } elseif ( $ m -> only_fields ) { $ added_fields = [ ] ; // Add requested fields first foreach ( $ m -> only_fields as $ field ) { $ f_object = $ m -> getField ( $ field ) ; if ( $ f_object -> never_persist ) { continue ; } $ this -> initField ( $ q , $ f_object ) ; $ added_fields [ $ field ] = true ; } // now add system fields, if they were not added foreach ( $ m -> elements as $ field => $ f_object ) { if ( $ f_object instanceof Field ) { if ( $ f_object -> never_persist ) { continue ; } if ( $ f_object -> system && ! isset ( $ added_fields [ $ field ] ) ) { $ this -> initField ( $ q , $ f_object ) ; } } } } else { foreach ( $ m -> elements as $ field => $ f_object ) { if ( $ f_object instanceof Field ) { if ( $ f_object -> never_persist ) { continue ; } $ this -> initField ( $ q , $ f_object ) ; } } } }
Adds model fields in Query.

@param Model            $m
@param \atk4\dsql\Query $q
@param array|null|false $fields
Adds model fields in Query .