在php中操作传递的参数


Manipulating passed arguments in php

我在php方面没有太多经验,我使用codeigniter来编写我的应用程序,我有自己的库,在我的库中有三个函数/方法,它们在我的一个模型中的一个函数中传递参数,我的问题是,我将如何操作/欺骗模型中的方法,以准确地知道库中三个函数中的哪个函数传递了值并返回正确的值。。

第一个功能

 public function id_exist ($id) {
      if(empty($id)) {
           return FALSE;
       }
      return $this->library_model->this_exist($id);
   }

第二个功能

 public function group_exist($group) {
       if(empty($group)){
           return FALSE;
       } 
       return $this->library_model->this_exist($group);  
   }

第三个与上述2个相同

在我的模型中

 public function this_exist ($item) {
              if(empty($item) || !isset($item)) {
                  return FALSE;
              }
         // here is where i need to know which function has passed the argument so that i can work with it and return the correct value from the database 

 }

可能脏,可能不复杂,但为什么不传递另一个参数,告诉确切的起源?

public function id_exist ($id) {
      if(empty($id)) {
           return FALSE;
       }
      return $this->library_model->this_exist('id', $id);
   }
public function group_exist($group) {
       if(empty($group)){
           return FALSE;
       } 
       return $this->library_model->this_exist('group', $group);  
   }

型号:

public function this_exist ($origin, $item) {
  if(empty($item) || !isset($item)) {
       return FALSE;
  }
  if($origin == 'id'){
   // do something
  }
  elseif($origin == 'group') {
   // do something else
  }
}