lundi 17 avril 2017

What´s the best pratice of adding functions in PHP Classes?

i have a class called filters.

that contains functions like getfilters, getname and set functions.

But in specific functions, ex:

class filters{

  $name,
  $filters,
  $where,
  $select,
  $order

  # set active columns
  public function setFilters($search){
      $this->filters = $search;
  }

  # set where on SQL
  public function setWhere(){

     foreach($this->filters as $col => $options){

        if($options['val'] == ''){continue;}

        if($options['Able_To_Search']){
           $this->where = $this->whereConstructor($col)
        } 

        if($options['join']){
          $this->join = $this->JoinConstructor($options['join'])
        }

        ... // and a lot of others functions to validate/format/order/permission on custom query.     

     }

  }

}

is this the best way to add new functions to a class ? and if i need other options in setWHere($options,$alias,$etc,$etc) for example ?

I would be grateful if i can know about it.

Aucun commentaire:

Enregistrer un commentaire