public function relative($name, array &$result) { if (empty($result)) { return []; } $pkeys = exec_method_array($this->model, 'getPKeys'); if (empty($pkeys)) { return []; } $fkey = $this->getForeignKey(); $values = $this->getAttrs($result); $this->queryMiddle($this->middle_table)->combine($values, $fkey, false); $an_fkey = $this->getAnotherForeignKey($name); $another_values = []; foreach ($values as $key => $value) { foreach ($value as $k => $val) { $index = $val->{$an_fkey}; $values[$key][$k] = $index; $another_values[$index] = null; } } $this->queryResult()->combine($another_values, reset($pkeys), true); foreach ($result as &$object) { $key = $object->getID(); if (!isset($values[$key])) { continue; } $objs = []; foreach ($values[$key] as $index) { $objs[] =& $another_values[$index]; } $object->{$name} = $objs; } return $another_values; }
public function __call($name, $args) { $method = self::getRequestMethod($name); if (!$method) { return exec_method_array(UniRequest, $name, $args); } $this->prepare(); @(list($url, $headers, $body) = $args); if (!empty($this->base_url)) { $url = $args[0] = $this->getURLString($url); } $try_times = 1; do { $phrase = ''; try { $result = exec_method_array(__NAMESPACE__ . '\\UniRequest', $name, $args); } catch (\Exception $e) { $phrase = $e->getMessage(); if (!isset($headers['Host']) && self::isUnreachable()) { $headers['Host'] = self::insteadOfURL($url); array_splice($args, 0, 2, [$url, $headers]); continue; //重试一次 } } $try_times--; } while ($try_times > 0); $body = self::getBodyString($body); $this->finish($result, $method, $url, $body, $headers, $phrase); return $result; }
/** * 设置图片格式 */ public function build(array $args = []) { $origin = [$this->width, $this->height, self::$font, self::$finger_print]; //$args后面缺少的元素使用$origin的元素补齐 exec_method_array($this->builder, 'build', $args + $origin); return $this->builder; }
public function __invoke() { if (!method_exists($this, $this->method)) { return $this->app->abort(403); } $args = func_get_args(); return exec_method_array($this, $this->method, $args); }
/** * 使用已定义的插件 */ public function __call($name, $args) { $name = strtolower($name); //PHP的方法名内部都是小写? if (isset($this->shortcuts[$name])) { list($plugin, $method) = $this->shortcuts[$name]; return exec_method_array($plugin, $method, $args); } }
public function test05ExecMethodArray() { $this->assertTrue(function_exists('exec_method_array')); $result = exec_method_array(new Sample(), 'sum', range(11, 14)); $this->assertEquals(array_sum(range(11, 14)) + 99, $result); $result = exec_method_array(new Sample(), 'sum', range(11, 15)); $this->assertEquals(array_sum(range(11, 15)), $result); $class = __NAMESPACE__ . '\\Sample'; $result = exec_method_array($class, 'sum', range(11, 13)); $this->assertEquals(array_sum(range(11, 13)) + 88 + 99, $result); $result = exec_method_array($class, 'sum', range(11, 15)); $this->assertEquals(array_sum(range(11, 15)), $result); }
public function reconnect() { if (!$this->isConnected()) { $connect = $this->options['persistent'] ? 'pconnect' : 'connect'; if (isset($this->options['socket'])) { $args = [$this->options['socket']]; } else { $args = [$this->host, $this->port]; } exec_method_array($this, $connect, $args); } return $this; }
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); } } }
public function relative($name, array &$result) { if (empty($result)) { return []; } $pkeys = exec_method_array($this->model, 'getPKeys'); if (empty($pkeys)) { return []; } $fkey = $this->getAnotherForeignKey($name); $values = $this->getAttrs($result, $fkey); $this->queryResult()->combine($values, reset($pkeys), true); $this->setAttrs($result, $values, $name, $fkey); return $values; }
public function relative($name, array &$result) { if (empty($result)) { return array(); } $pkeys = exec_method_array($this->model, 'getPKeys'); if (empty($pkeys)) { return array(); } $fkey = $this->getForeignKey($name); $values = $this->getAttrs($result, $fkey); $query = $this->newQuery(); $query->combine(reset($pkeys), $values, true); $this->setAttrs($result, $values, $name, $fkey); return $values; }
/** * 使用已定义的插件 */ public function __call($name, $args) { $name = strtolower($name); //PHP的方法名内部都是小写? if (isset($this->shortcuts[$name])) { $shortcut = $this->shortcuts[$name]; if (is_array($shortcut)) { @(list($plugin, $name) = $shortcut); } else { $plugin =& $this->shortcuts[$name]; } return exec_method_array($plugin, $name, $args); } }
public function route() { $router = \Cute\Web\Router::getCurrent(); $args = func_get_args(); return exec_method_array($router, 'route', $args); }
public function __call($name, $args) { if (method_exists($this->query, $name)) { exec_method_array($this->query, $name, $args); return $this; } else { var_dump($name, $args); $stmt = exec_method_array($this->query, 'apply', $args); $column = $stmt->fetchColumn(); $stmt->closeCursor(); return $column; } }
public function writeln($text) { $args = func_get_args(); $args[0] .= PHP_EOL; return exec_method_array($this, 'write', $args); }
public function execute() { $action = strval(reset($this->args)); $args = array_slice($this->args, 1); return exec_method_array($this, $action, $args); }
function build(array $B = array()) { $UE = array($this->width, $this->height, $this->font, $this->finger_print); exec_method_array($this->builder, 'build', $B + $UE); return $this->builder; }
/** * 获取单个Model对象或null */ public function get($id, $key = false, $columns = '*') { if (empty($key)) { $pkeys = exec_method_array($this->getModel(), 'getPKeys'); if (empty($pkeys)) { return; } $key = reset($pkeys); } $objs = $this->setPage(1)->all($columns, "{$key} = ?", $id); return count($objs) > 0 ? reset($objs) : null; }
public function getPKey() { $pkeys = exec_method_array($this->getModel(), 'getPKeys'); return empty($pkeys) ? null : reset($pkeys); }