Esempio n. 1
0
 public function write($text)
 {
     if (func_num_args() > 1) {
         $text = exec_function_array('sprintf', func_get_args());
     }
     return self::appendTo($text, $this->color, $this->outfile);
 }
Esempio n. 2
0
 /**
  * 获取当前网址对应handlers,并从后向前运行第一个拦截成功的
  */
 public function run()
 {
     $route_key = $this->getConfig('route_key', 'r');
     $path = $this->input('GET')->get($route_key, '/');
     try {
         $route = $this->dispatch($path);
         $succor = null;
         foreach ($route['handlers'] as $handler) {
             if ($handler && class_exists($handler, true)) {
                 $handler = new $handler($succor);
             }
             if ($handler && is_callable($handler)) {
                 $succor =& $handler;
             }
         }
         if ($succor) {
             $this->url = $route['url'];
             $this->rule = $route['rule'];
             $output = exec_function_array($succor, $route['args']);
         }
     } catch (\Exception $e) {
         $output = strval($e);
     }
     return die($output);
 }
Esempio n. 3
0
 public function test04ExecFunctionArray()
 {
     $this->assertTrue(function_exists('exec_function_array'));
     $result = exec_function_array('strtolower', array(__FUNCTION__));
     $this->assertEquals(strtolower(__FUNCTION__), $result);
     $args = range(11, 20);
     $result = exec_function_array(new Sample(), $args);
     $this->assertEquals(array_sum($args), $result);
 }
Esempio n. 4
0
 /**
  * 更新全局变量,全局变量可作为编译器变量
  * @param array $globals 全局变量数组
  * @param array ... 其他全局变量数组
  */
 public function updateGlobals(array $globals)
 {
     if (func_num_args() === 1) {
         $this->globals = array_merge($this->globals, $globals);
     } else {
         $args = func_get_args();
         array_unshift($args, $this->globals);
         $this->globals = exec_function_array('array_merge', $args);
     }
     return $this;
 }
Esempio n. 5
0
 public function __invoke()
 {
     $method = $this->app->getMethod();
     $args = func_get_args();
     if ($method = $this->init($method)) {
         return exec_method_array($this, $method, $args);
     } else {
         if ($this->succor) {
             return exec_function_array($this->succor, $args);
         } else {
             return $this->app->abort(403);
         }
     }
 }
Esempio n. 6
0
 public function execDigest($origin)
 {
     if ($this->digest) {
         return exec_function_array($this->digest, [$origin]);
     }
 }
Esempio n. 7
0
 protected function parseWhere()
 {
     if ($this->nothing) {
         return ['WHERE 1=0', []];
     }
     $where = '';
     $params = [];
     if ($this->constrains) {
         $where = implode(' AND ', array_keys($this->constrains));
         $params = exec_function_array('array_merge', array_values($this->constrains));
     }
     if ($this->or_constrains) {
         $or_where = '(' . implode(') OR (', array_keys($this->or_constrains)) . ')';
         $or_params = exec_function_array('array_merge', array_values($this->or_constrains));
         $where = empty($where) ? $or_where : '(' . $where . ') OR (' . $or_where . ')';
         $params = empty($params) ? $or_params : array_merge($params, $or_params);
     }
     $where = empty($where) ? '' : 'WHERE ' . $where;
     return [$where, $params];
 }
Esempio n. 8
0
 /**
  * 获取范围内数据
  * @param string $key 索引名
  * @param mixed $value 索引值
  *          ... $value2 其他索引值
  * @return array/false
  */
 public function in($key, $value)
 {
     $actions = array();
     $values = array_slice(func_get_args(), 1);
     //兼容第二个参数传索引值数组的用法
     if (count($values) === 1 && is_array($values[0])) {
         $values = $values[0];
     }
     foreach ($values as $value) {
         $actions[] = array('find', $value);
     }
     $result = $this->prepare($key)->multi($actions);
     if ($result === false) {
         return false;
         //查询失败
     }
     $rows = exec_function_array('array_merge', $result);
     foreach ($rows as &$row) {
         $row = array_combine($this->fields, $row);
     }
     return $rows;
     //向量数组
 }
Esempio n. 9
0
 function updateGlobals(array $LE)
 {
     if (func_num_args() === 1) {
         $this->globals = array_merge($this->globals, $LE);
     } else {
         $B = func_get_args();
         array_unshift($B, $this->globals);
         $this->globals = exec_function_array('array_merge', $B);
     }
     return $this;
 }