2016-10-13 3 views
0
public function groups() 
{ 
    $this->trigger_events('groups'); 

    // run each where that was passed 
    if (isset($this->_ion_where) && !empty($this->_ion_where)) 
    { 
     foreach ($this->_ion_where as $where) 
     { 
      $this->db->where($where); 
     } 
     $this->_ion_where = array(); 
    } 

    if (isset($this->_ion_limit) && isset($this->_ion_offset)) 
    { 
     $this->db->limit($this->_ion_limit, $this->_ion_offset); 

     $this->_ion_limit = NULL; 
     $this->_ion_offset = NULL; 
    } 
    else if (isset($this->_ion_limit)) 
    { 
     $this->db->limit($this->_ion_limit); 

     $this->_ion_limit = NULL; 
    } 

    // set the order 
    if (isset($this->_ion_order_by) && isset($this->_ion_order)) 
    { 
     $this->db->order_by($this->_ion_order_by, $this->_ion_order); 
    } 

    $this->response = $this->db->get($this->tables['groups']); 

    return $this; 
} 

을 제공하는 네이티브를 사용하는 이온 인증 라이브러리를 사용하는 사용자 정의 곳() 함수 위의 정의 _ion_limit을 사용하는 이유, _ion_offset, _ion_where CI가 이미() -> limit() -> get() 네이티브를 작성할 수있는 선택권을 부여했을 때 자체 private _ion_limit, _ion_offset, _ion_where 개인 속성을 유지하면 워크 플로에 좋은 점이 있습니까? 여기서 어떤 부분을 놓치거나 여기에 어떤 디자인 패턴이 관련되어 있습니까?왜 대신() CI는() 그룹에서 볼 수 있듯이 그것은 나에게 말도 안되는 것 같습니다

답변

0

주된 이유는 이벤트 후크 기능을 구현하는 것입니다. 모든 "중복"db 함수는 에 제공된 함수를 차례로 호출하는 $this->trigger_events()을 호출합니다.

나는 다른 괜찮은 이유를 알았는지에 대해 정말로 모호한 추억을 가지고 있습니다. 그러나 그것은 꽤 오랜 시간이었고, 나는 그것이 무엇인지를 기억할 수 없다.

+0

아마도 사실, 그것은 SQL 구문을 더 유연하게 만드는 것처럼 보입니다. – user7031