Model::__call PHP Method

__call() public method

In this case we are attempting to convert camel case formatted methods into underscore formatted methods. This allows us to call methods using camel case and remain backwards compatible.
public __call ( string $name, array $arguments ) : boolean | ORMWrapper
$name string
$arguments array
return boolean | ORMWrapper
    public function __call($name, $arguments)
    {
        $method = strtolower(preg_replace('/([a-z])([A-Z])/', '$1_$2', $name));
        if (method_exists($this, $method)) {
            return call_user_func_array(array($this, $method), $arguments);
        } else {
            throw new ParisMethodMissingException("Method {$name}() does not exist in class " . get_class($this));
        }
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * 魔术方法用于动态执行Db类中的方法
  * @param $method
  * @param $param
  * @return mixed
  */
 public function __call($method, $param)
 {
     if (in_array($method, $this->queryMethod)) {
         $this->setDriverOption();
     }
     /**
      * 调用父类方法完成查询操作
      */
     return parent::__call($method, $param);
 }
All Usage Examples Of Model::__call