repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
matyhtf/framework
libs/Swoole/Record.php
Record.put
function put($data) { if ($this->_change == self::STATE_INSERT) { $this->_change = self::STATE_UPDATE; $this->_update = $data; } elseif ($this->_change == self::STATE_EMPTY) { $this->_change = self::STATE_INSERT; $this->_data = ...
php
function put($data) { if ($this->_change == self::STATE_INSERT) { $this->_change = self::STATE_UPDATE; $this->_update = $data; } elseif ($this->_change == self::STATE_EMPTY) { $this->_change = self::STATE_INSERT; $this->_data = ...
[ "function", "put", "(", "$", "data", ")", "{", "if", "(", "$", "this", "->", "_change", "==", "self", "::", "STATE_INSERT", ")", "{", "$", "this", "->", "_change", "=", "self", "::", "STATE_UPDATE", ";", "$", "this", "->", "_update", "=", "$", "dat...
将关联数组压入object中,赋值给各个字段 @param $data @return void
[ "将关联数组压入object中,赋值给各个字段" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Record.php#L89-L101
matyhtf/framework
libs/Swoole/Record.php
Record.save
function save() { $this->_save = false; if ($this->_change == 0 or $this->_change == 1) { if ($this->db->insert($this->_data, $this->table) === false) { return false; } //改变状态 $this->_change = 1; $this->_...
php
function save() { $this->_save = false; if ($this->_change == 0 or $this->_change == 1) { if ($this->db->insert($this->_data, $this->table) === false) { return false; } //改变状态 $this->_change = 1; $this->_...
[ "function", "save", "(", ")", "{", "$", "this", "->", "_save", "=", "false", ";", "if", "(", "$", "this", "->", "_change", "==", "0", "or", "$", "this", "->", "_change", "==", "1", ")", "{", "if", "(", "$", "this", "->", "db", "->", "insert", ...
保存对象数据到数据库 如果是空白的记录,保存则会Insert到数据库 如果是已存在的记录,保持则会update,修改过的值,如果没有任何值被修改,则不执行SQL @return bool
[ "保存对象数据到数据库", "如果是空白的记录,保存则会Insert到数据库", "如果是已存在的记录,保持则会update,修改过的值,如果没有任何值被修改,则不执行SQL" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Record.php#L161-L185
matyhtf/framework
libs/Swoole/Record.php
Record.delete
function delete() { if ($this->db->delete($this->_current_id, $this->table, $this->primary) === false) { return false; } $this->_delete = true; $this->notify(); return true; }
php
function delete() { if ($this->db->delete($this->_current_id, $this->table, $this->primary) === false) { return false; } $this->_delete = true; $this->notify(); return true; }
[ "function", "delete", "(", ")", "{", "if", "(", "$", "this", "->", "db", "->", "delete", "(", "$", "this", "->", "_current_id", ",", "$", "this", "->", "table", ",", "$", "this", "->", "primary", ")", "===", "false", ")", "{", "return", "false", ...
删除数据库中的此条记录 @return bool
[ "删除数据库中的此条记录" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Record.php#L211-L220
matyhtf/framework
libs/module/GetOptionKit/src/GetOptionKit/GetOptionKit.php
GetOptionKit.add
function add( $specString, $description , $key = null ) { $spec = $this->specs->add($specString,$description,$key); return $spec; }
php
function add( $specString, $description , $key = null ) { $spec = $this->specs->add($specString,$description,$key); return $spec; }
[ "function", "add", "(", "$", "specString", ",", "$", "description", ",", "$", "key", "=", "null", ")", "{", "$", "spec", "=", "$", "this", "->", "specs", "->", "add", "(", "$", "specString", ",", "$", "description", ",", "$", "key", ")", ";", "re...
/* a helper to build option specification object from string spec @param $specString string @param $description string @param $key
[ "/", "*", "a", "helper", "to", "build", "option", "specification", "object", "from", "string", "spec" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/module/GetOptionKit/src/GetOptionKit/GetOptionKit.php#L56-L60
matyhtf/framework
libs/Swoole/Server/LinuxTCP.php
LinuxTCP.init_pcntl
function init_pcntl() { if (isset($this->cfg['pcntl']['daemon'])) { $this->daemon(); } $this->main_pid = posix_getpid(); if (isset($this->cfg['pcntl']['user'])) { $user = posix_getpwnam($this->cfg['pcntl']['user']); $this->setuid($user...
php
function init_pcntl() { if (isset($this->cfg['pcntl']['daemon'])) { $this->daemon(); } $this->main_pid = posix_getpid(); if (isset($this->cfg['pcntl']['user'])) { $user = posix_getpwnam($this->cfg['pcntl']['user']); $this->setuid($user...
[ "function", "init_pcntl", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "cfg", "[", "'pcntl'", "]", "[", "'daemon'", "]", ")", ")", "{", "$", "this", "->", "daemon", "(", ")", ";", "}", "$", "this", "->", "main_pid", "=", "posix_getp...
根据配置初始化服务器
[ "根据配置初始化服务器" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Server/LinuxTCP.php#L30-L50
matyhtf/framework
libs/Swoole/Server/LinuxTCP.php
LinuxTCP.clean_socket
function clean_socket() { if (empty($this->server->client_sock)) { return true; } foreach ($this->server->client_sock as $k => $fd) { //echo $this->context[$k]['time'],"\t",$this->socket_life,"\t",$this->server_time,"\n"; if ($this->context...
php
function clean_socket() { if (empty($this->server->client_sock)) { return true; } foreach ($this->server->client_sock as $k => $fd) { //echo $this->context[$k]['time'],"\t",$this->socket_life,"\t",$this->server_time,"\n"; if ($this->context...
[ "function", "clean_socket", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "server", "->", "client_sock", ")", ")", "{", "return", "true", ";", "}", "foreach", "(", "$", "this", "->", "server", "->", "client_sock", "as", "$", "k", "=>", ...
清理socket
[ "清理socket" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Server/LinuxTCP.php#L84-L98
matyhtf/framework
libs/Swoole/Client/WebSocket.php
WebSocket.connect
public function connect($timeout = 0.5) { if (extension_loaded('swoole')) { $type = preg_match('/^[0-9\.]+$/', $this->host) ? SWOOLE_SOCK_TCP : SWOOLE_SOCK_UNIX_STREAM; if ($this->ssl) { $type |= SWOOLE_SSL; } $this->socket ...
php
public function connect($timeout = 0.5) { if (extension_loaded('swoole')) { $type = preg_match('/^[0-9\.]+$/', $this->host) ? SWOOLE_SOCK_TCP : SWOOLE_SOCK_UNIX_STREAM; if ($this->ssl) { $type |= SWOOLE_SSL; } $this->socket ...
[ "public", "function", "connect", "(", "$", "timeout", "=", "0.5", ")", "{", "if", "(", "extension_loaded", "(", "'swoole'", ")", ")", "{", "$", "type", "=", "preg_match", "(", "'/^[0-9\\.]+$/'", ",", "$", "this", "->", "host", ")", "?", "SWOOLE_SOCK_TCP"...
Connect client to server @param float $timeout @return bool
[ "Connect", "client", "to", "server" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Client/WebSocket.php#L100-L154
matyhtf/framework
libs/Swoole/Client/WebSocket.php
WebSocket.doHandShake
function doHandShake($headerBuffer) { $header = Swoole\Http\Parser::parseHeader($headerBuffer); $_header_key_low_case = array_change_key_case($header, CASE_LOWER); if (!isset($_header_key_low_case['sec-websocket-accept'])) { $this->disconnect(); return false; ...
php
function doHandShake($headerBuffer) { $header = Swoole\Http\Parser::parseHeader($headerBuffer); $_header_key_low_case = array_change_key_case($header, CASE_LOWER); if (!isset($_header_key_low_case['sec-websocket-accept'])) { $this->disconnect(); return false; ...
[ "function", "doHandShake", "(", "$", "headerBuffer", ")", "{", "$", "header", "=", "Swoole", "\\", "Http", "\\", "Parser", "::", "parseHeader", "(", "$", "headerBuffer", ")", ";", "$", "_header_key_low_case", "=", "array_change_key_case", "(", "$", "header", ...
握手 @param $headerBuffer @return bool
[ "握手" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Client/WebSocket.php#L161-L178
matyhtf/framework
libs/Swoole/Client/WebSocket.php
WebSocket.recv
function recv() { if (!$this->handshake) { trigger_error("not complete handshake."); return false; } if ($this->buffer and $offset = stripos($this->buffer,"\r\n\r\n") !== false) { $packet = substr($this->buffer, 0, $offset + 4); ...
php
function recv() { if (!$this->handshake) { trigger_error("not complete handshake."); return false; } if ($this->buffer and $offset = stripos($this->buffer,"\r\n\r\n") !== false) { $packet = substr($this->buffer, 0, $offset + 4); ...
[ "function", "recv", "(", ")", "{", "if", "(", "!", "$", "this", "->", "handshake", ")", "{", "trigger_error", "(", "\"not complete handshake.\"", ")", ";", "return", "false", ";", "}", "if", "(", "$", "this", "->", "buffer", "and", "$", "offset", "=", ...
接收数据 @return bool | Swoole\Http\WebSocketFrame @throws Swoole\Http\WebSocketException
[ "接收数据" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Client/WebSocket.php#L194-L235
matyhtf/framework
libs/Swoole/Client/WebSocket.php
WebSocket.send
public function send($data, $type = 'text', $masked = true) { if (empty($data)) { throw new \Exception("data is empty"); } if (!$this->handshake) { trigger_error("not complete handshake."); return false; } if ($this->haveSwo...
php
public function send($data, $type = 'text', $masked = true) { if (empty($data)) { throw new \Exception("data is empty"); } if (!$this->handshake) { trigger_error("not complete handshake."); return false; } if ($this->haveSwo...
[ "public", "function", "send", "(", "$", "data", ",", "$", "type", "=", "'text'", ",", "$", "masked", "=", "true", ")", "{", "if", "(", "empty", "(", "$", "data", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "\"data is empty\"", ")", ";", ...
send string data @param $data @param string $type @param bool $masked @throws \Exception @return bool
[ "send", "string", "data" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Client/WebSocket.php#L245-L277
matyhtf/framework
libs/Swoole/Client/WebSocket.php
WebSocket.createHeader
final protected function createHeader() { $host = $this->host; if ($host === '127.0.0.1' || $host === '0.0.0.0') { $host = 'localhost'; } return "GET {$this->path} HTTP/1.1" . "\r\n" . "Origin: null" . "\r\n" . "Host: {$host}:{$this->port}" . "\r\...
php
final protected function createHeader() { $host = $this->host; if ($host === '127.0.0.1' || $host === '0.0.0.0') { $host = 'localhost'; } return "GET {$this->path} HTTP/1.1" . "\r\n" . "Origin: null" . "\r\n" . "Host: {$host}:{$this->port}" . "\r\...
[ "final", "protected", "function", "createHeader", "(", ")", "{", "$", "host", "=", "$", "this", "->", "host", ";", "if", "(", "$", "host", "===", "'127.0.0.1'", "||", "$", "host", "===", "'0.0.0.0'", ")", "{", "$", "host", "=", "'localhost'", ";", "}...
Create header for websocket client @return string
[ "Create", "header", "for", "websocket", "client" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Client/WebSocket.php#L294-L311
matyhtf/framework
libs/Swoole/Client/WebSocket.php
WebSocket.parseIncomingRaw
final protected function parseIncomingRaw($header) { $retval = array(); $content = ""; $fields = explode("\r\n", preg_replace('/\x0D\x0A[\x09\x20]+/', ' ', $header)); foreach ($fields as $field) { if (preg_match('/([^:]+): (.+)/m', $field, $match)) { $matc...
php
final protected function parseIncomingRaw($header) { $retval = array(); $content = ""; $fields = explode("\r\n", preg_replace('/\x0D\x0A[\x09\x20]+/', ' ', $header)); foreach ($fields as $field) { if (preg_match('/([^:]+): (.+)/m', $field, $match)) { $matc...
[ "final", "protected", "function", "parseIncomingRaw", "(", "$", "header", ")", "{", "$", "retval", "=", "array", "(", ")", ";", "$", "content", "=", "\"\"", ";", "$", "fields", "=", "explode", "(", "\"\\r\\n\"", ",", "preg_replace", "(", "'/\\x0D\\x0A[\\x0...
Parse raw incoming data @param $header @return array
[ "Parse", "raw", "incoming", "data" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Client/WebSocket.php#L319-L343
matyhtf/framework
libs/Swoole/Client/WebSocket.php
WebSocket.generateToken
private function generateToken($length) { $characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"§$%&/()=[]{}'; $useChars = array(); // select some random chars: for ($i = 0; $i < $length; $i++) { $useChars[] = $characters[mt_rand(0, strlen($characters) - 1...
php
private function generateToken($length) { $characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"§$%&/()=[]{}'; $useChars = array(); // select some random chars: for ($i = 0; $i < $length; $i++) { $useChars[] = $characters[mt_rand(0, strlen($characters) - 1...
[ "private", "function", "generateToken", "(", "$", "length", ")", "{", "$", "characters", "=", "'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!\"§$%&/()=[]{}';", "", "$", "useChars", "=", "array", "(", ")", ";", "// select some random chars:", "for", "(", "$", "...
Generate token @param int $length @return string
[ "Generate", "token" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Client/WebSocket.php#L351-L367
matyhtf/framework
libs/Swoole/Client/WebSocket.php
WebSocket.generateAlphaNumToken
public function generateAlphaNumToken($length) { $characters = str_split('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'); srand((float)microtime() * 1000000); $token = ''; do { shuffle($characters); $token .= $characters[mt_rand(0,...
php
public function generateAlphaNumToken($length) { $characters = str_split('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'); srand((float)microtime() * 1000000); $token = ''; do { shuffle($characters); $token .= $characters[mt_rand(0,...
[ "public", "function", "generateAlphaNumToken", "(", "$", "length", ")", "{", "$", "characters", "=", "str_split", "(", "'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'", ")", ";", "srand", "(", "(", "float", ")", "microtime", "(", ")", "*", "1000000...
Generate token @param int $length @return string
[ "Generate", "token" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Client/WebSocket.php#L375-L390
matyhtf/framework
libs/Swoole/RandomKey.php
RandomKey.string
static function string($length = 8, $number = true, $ignore = array('0', 'o', 'l', '1', 'i')) { $strings = 'ABCDEFGHIJKLOMNOPQRSTUVWXYZ'; //字符池 $numbers = '0123456789'; //数字池 if ($ignore and is_array($ignore)) { $strings = str_replace($ignore, '', $str...
php
static function string($length = 8, $number = true, $ignore = array('0', 'o', 'l', '1', 'i')) { $strings = 'ABCDEFGHIJKLOMNOPQRSTUVWXYZ'; //字符池 $numbers = '0123456789'; //数字池 if ($ignore and is_array($ignore)) { $strings = str_replace($ignore, '', $str...
[ "static", "function", "string", "(", "$", "length", "=", "8", ",", "$", "number", "=", "true", ",", "$", "ignore", "=", "array", "(", "'0'", ",", "'o'", ",", "'l'", ",", "'1'", ",", "'i'", ")", ")", "{", "$", "strings", "=", "'ABCDEFGHIJKLOMNOPQRST...
随机生成一个字符串 @param $length @param bool $number 只添加数字 @param array $ignore 忽略某些字符串 @return string
[ "随机生成一个字符串" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/RandomKey.php#L26-L44
matyhtf/framework
libs/Swoole/RandomKey.php
RandomKey.randtime
static function randtime($rand_length = 6) { list($usec, $sec) = explode(" ", microtime()); $min = intval('1' . str_repeat('0', $rand_length - 1)); $max = intval(str_repeat('9', $rand_length)); return substr($sec, -5) . ((int)$usec * 100) . rand($min, $max); }
php
static function randtime($rand_length = 6) { list($usec, $sec) = explode(" ", microtime()); $min = intval('1' . str_repeat('0', $rand_length - 1)); $max = intval(str_repeat('9', $rand_length)); return substr($sec, -5) . ((int)$usec * 100) . rand($min, $max); }
[ "static", "function", "randtime", "(", "$", "rand_length", "=", "6", ")", "{", "list", "(", "$", "usec", ",", "$", "sec", ")", "=", "explode", "(", "\" \"", ",", "microtime", "(", ")", ")", ";", "$", "min", "=", "intval", "(", "'1'", ".", "str_re...
按UNIX时间戳产生随机数 @param $rand_length @return string
[ "按UNIX时间戳产生随机数" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/RandomKey.php#L62-L68
matyhtf/framework
libs/Swoole/RandomKey.php
RandomKey.randmd5
static function randmd5($length = 8, $seed = null) { if (empty($seed)) { $seed = self::string(16); } return substr(md5($seed . rand(111111, 999999)), 0, $length); }
php
static function randmd5($length = 8, $seed = null) { if (empty($seed)) { $seed = self::string(16); } return substr(md5($seed . rand(111111, 999999)), 0, $length); }
[ "static", "function", "randmd5", "(", "$", "length", "=", "8", ",", "$", "seed", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "seed", ")", ")", "{", "$", "seed", "=", "self", "::", "string", "(", "16", ")", ";", "}", "return", "substr",...
产生一个随机MD5字符的一部分 @param $length @param $seed @return string
[ "产生一个随机MD5字符的一部分" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/RandomKey.php#L76-L82
matyhtf/framework
libs/Swoole/Client/CoURL.php
CoURL.get
function get($url, $callback = null) { $ret = new CoURLResult($url, $callback, $this->handle); $ret->method = self::METHOD_GET; $this->requests[$ret->id] = $ret; return $ret; }
php
function get($url, $callback = null) { $ret = new CoURLResult($url, $callback, $this->handle); $ret->method = self::METHOD_GET; $this->requests[$ret->id] = $ret; return $ret; }
[ "function", "get", "(", "$", "url", ",", "$", "callback", "=", "null", ")", "{", "$", "ret", "=", "new", "CoURLResult", "(", "$", "url", ",", "$", "callback", ",", "$", "this", "->", "handle", ")", ";", "$", "ret", "->", "method", "=", "self", ...
GET请求 @param $url @param null $callback @return CoURLResult
[ "GET请求" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Client/CoURL.php#L23-L29
matyhtf/framework
libs/Swoole/Client/CoURL.php
CoURL.post
function post($url, $data, $callback = null) { $ret = new CoURLResult($url, $callback, $this->handle); $ret->method = self::METHOD_POST; $ret->data = $data; $this->requests[$ret->id] = $ret; return $ret; }
php
function post($url, $data, $callback = null) { $ret = new CoURLResult($url, $callback, $this->handle); $ret->method = self::METHOD_POST; $ret->data = $data; $this->requests[$ret->id] = $ret; return $ret; }
[ "function", "post", "(", "$", "url", ",", "$", "data", ",", "$", "callback", "=", "null", ")", "{", "$", "ret", "=", "new", "CoURLResult", "(", "$", "url", ",", "$", "callback", ",", "$", "this", "->", "handle", ")", ";", "$", "ret", "->", "met...
POST请求 @param $url @param null $callback @return CoURLResult
[ "POST请求" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Client/CoURL.php#L37-L44
matyhtf/framework
libs/Swoole/Loader.php
Loader.loadModel
static function loadModel($model_name) { if (isset(self::$_objects['model'][$model_name])) { return self::$_objects['model'][$model_name]; } else { $model_file = \Swoole::$app_path . '/models/' . $model_name . '.model.php'; if(!file_exists(...
php
static function loadModel($model_name) { if (isset(self::$_objects['model'][$model_name])) { return self::$_objects['model'][$model_name]; } else { $model_file = \Swoole::$app_path . '/models/' . $model_name . '.model.php'; if(!file_exists(...
[ "static", "function", "loadModel", "(", "$", "model_name", ")", "{", "if", "(", "isset", "(", "self", "::", "$", "_objects", "[", "'model'", "]", "[", "$", "model_name", "]", ")", ")", "{", "return", "self", "::", "$", "_objects", "[", "'model'", "]"...
加载一个模型对象 @param $model_name string 模型名称 @return $model_object 模型对象
[ "加载一个模型对象" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Loader.php#L47-L67
matyhtf/framework
libs/Swoole/Loader.php
Loader.autoload
static function autoload($class) { $root = explode('\\', trim($class, '\\'), 2); if (count($root) > 1 and isset(self::$namespaces[$root[0]])) { include self::$namespaces[$root[0]].'/'.str_replace('\\', '/', $root[1]).'.php'; } }
php
static function autoload($class) { $root = explode('\\', trim($class, '\\'), 2); if (count($root) > 1 and isset(self::$namespaces[$root[0]])) { include self::$namespaces[$root[0]].'/'.str_replace('\\', '/', $root[1]).'.php'; } }
[ "static", "function", "autoload", "(", "$", "class", ")", "{", "$", "root", "=", "explode", "(", "'\\\\'", ",", "trim", "(", "$", "class", ",", "'\\\\'", ")", ",", "2", ")", ";", "if", "(", "count", "(", "$", "root", ")", ">", "1", "and", "isse...
自动载入类 @param $class
[ "自动载入类" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Loader.php#L73-L80
matyhtf/framework
libs/Swoole/Cache/Memcache.php
Memcache.formatConfig
protected function formatConfig(&$cf) { if (empty($cf['host'])) { $cf['host'] = self::DEFAULT_HOST; } if (empty($cf['port'])) { $cf['port'] = self::DEFAULT_PORT; } if (empty($cf['weight'])) { $cf['weight'] = 1; ...
php
protected function formatConfig(&$cf) { if (empty($cf['host'])) { $cf['host'] = self::DEFAULT_HOST; } if (empty($cf['port'])) { $cf['port'] = self::DEFAULT_PORT; } if (empty($cf['weight'])) { $cf['weight'] = 1; ...
[ "protected", "function", "formatConfig", "(", "&", "$", "cf", ")", "{", "if", "(", "empty", "(", "$", "cf", "[", "'host'", "]", ")", ")", "{", "$", "cf", "[", "'host'", "]", "=", "self", "::", "DEFAULT_HOST", ";", "}", "if", "(", "empty", "(", ...
格式化配置 @param $cf @return null
[ "格式化配置" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Cache/Memcache.php#L73-L91
matyhtf/framework
libs/Swoole/Cache/Memcache.php
Memcache.addServer
protected function addServer($cf) { $this->formatConfig($cf); if ($this->memcached) { $this->cache->addServer($cf['host'], $cf['port'], $cf['weight']); } else { $this->cache->addServer($cf['host'], $cf['port'], $cf['persistent'], $cf['weight'])...
php
protected function addServer($cf) { $this->formatConfig($cf); if ($this->memcached) { $this->cache->addServer($cf['host'], $cf['port'], $cf['weight']); } else { $this->cache->addServer($cf['host'], $cf['port'], $cf['persistent'], $cf['weight'])...
[ "protected", "function", "addServer", "(", "$", "cf", ")", "{", "$", "this", "->", "formatConfig", "(", "$", "cf", ")", ";", "if", "(", "$", "this", "->", "memcached", ")", "{", "$", "this", "->", "cache", "->", "addServer", "(", "$", "cf", "[", ...
增加节点服务器 @param $cf @return null
[ "增加节点服务器" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Cache/Memcache.php#L98-L109
matyhtf/framework
libs/Swoole/Cache/Memcache.php
Memcache.set
function set($key, $value, $expire = 0) { if ($this->memcached) { return $this->cache->set($key, $value, $expire); } else { return $this->cache->set($key, $value, $this->flags, $expire); } }
php
function set($key, $value, $expire = 0) { if ($this->memcached) { return $this->cache->set($key, $value, $expire); } else { return $this->cache->set($key, $value, $this->flags, $expire); } }
[ "function", "set", "(", "$", "key", ",", "$", "value", ",", "$", "expire", "=", "0", ")", "{", "if", "(", "$", "this", "->", "memcached", ")", "{", "return", "$", "this", "->", "cache", "->", "set", "(", "$", "key", ",", "$", "value", ",", "$...
设置 @param $key @param $value @param int $expire @return bool
[ "设置" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Cache/Memcache.php#L128-L138
matyhtf/framework
libs/Swoole/Protocol/FastCGI.php
FastCGI.response
public function response($req, $out) { $cs = $chunksize = 8192; if (strlen($out) > $cs) { while (($ol = strlen($out)) > 0) { $l = min($cs, $ol); if ($this->sendChunk($req, substr($out, 0, $l)) === false) { ...
php
public function response($req, $out) { $cs = $chunksize = 8192; if (strlen($out) > $cs) { while (($ol = strlen($out)) > 0) { $l = min($cs, $ol); if ($this->sendChunk($req, substr($out, 0, $l)) === false) { ...
[ "public", "function", "response", "(", "$", "req", ",", "$", "out", ")", "{", "$", "cs", "=", "$", "chunksize", "=", "8192", ";", "if", "(", "strlen", "(", "$", "out", ")", ">", "$", "cs", ")", "{", "while", "(", "(", "$", "ol", "=", "strlen"...
Handles the output from downstream requests. @param object Request. @param string The output. @return boolean Success
[ "Handles", "the", "output", "from", "downstream", "requests", "." ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Protocol/FastCGI.php#L188-L210
matyhtf/framework
libs/Swoole/Protocol/FastCGI.php
FastCGI.sendChunk
public function sendChunk($req, $chunk) { return $this->server->send($req->fd, "\x01" // protocol version . "\x06" // record type (STDOUT) . pack('nn', $req->id, strlen($chunk)) // id, content length . "\x00" // padding length . "\x00" // reserved ...
php
public function sendChunk($req, $chunk) { return $this->server->send($req->fd, "\x01" // protocol version . "\x06" // record type (STDOUT) . pack('nn', $req->id, strlen($chunk)) // id, content length . "\x00" // padding length . "\x00" // reserved ...
[ "public", "function", "sendChunk", "(", "$", "req", ",", "$", "chunk", ")", "{", "return", "$", "this", "->", "server", "->", "send", "(", "$", "req", "->", "fd", ",", "\"\\x01\"", "// protocol version", ".", "\"\\x06\"", "// record type (STDOUT)", ".", "p...
Sends a chunk @param $req @param $chunk @return bool
[ "Sends", "a", "chunk" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Protocol/FastCGI.php#L218-L227
matyhtf/framework
libs/Swoole/Protocol/FastCGI.php
FastCGI.endRequest
public function endRequest($req, $appStatus = 0, $protoStatus = 0) { $c = pack('NC', $appStatus, $protoStatus) // app status, protocol status . "\x00\x00\x00"; $this->server->send($req->fd, "\x01" // protocol version . "\x03" // record type (END_REQUEST) ...
php
public function endRequest($req, $appStatus = 0, $protoStatus = 0) { $c = pack('NC', $appStatus, $protoStatus) // app status, protocol status . "\x00\x00\x00"; $this->server->send($req->fd, "\x01" // protocol version . "\x03" // record type (END_REQUEST) ...
[ "public", "function", "endRequest", "(", "$", "req", ",", "$", "appStatus", "=", "0", ",", "$", "protoStatus", "=", "0", ")", "{", "$", "c", "=", "pack", "(", "'NC'", ",", "$", "appStatus", ",", "$", "protoStatus", ")", "// app status, protocol status", ...
Handles the output from downstream requests. @param $req @param $appStatus @param $protoStatus @return void
[ "Handles", "the", "output", "from", "downstream", "requests", "." ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Protocol/FastCGI.php#L236-L256
matyhtf/framework
libs/Swoole/Limit.php
Limit.addCount
function addCount($key, $expire = 86400, $incrby = 1) { $key = self::PREFIX.$key; //增加计数 if ($this->redis->exists($key)) { return $this->redis->incr($key, $incrby); } //不存在的Key,设置为1 else { return $this->redis->set($key, $incrby,...
php
function addCount($key, $expire = 86400, $incrby = 1) { $key = self::PREFIX.$key; //增加计数 if ($this->redis->exists($key)) { return $this->redis->incr($key, $incrby); } //不存在的Key,设置为1 else { return $this->redis->set($key, $incrby,...
[ "function", "addCount", "(", "$", "key", ",", "$", "expire", "=", "86400", ",", "$", "incrby", "=", "1", ")", "{", "$", "key", "=", "self", "::", "PREFIX", ".", "$", "key", ";", "//增加计数", "if", "(", "$", "this", "->", "redis", "->", "exists", "...
增加计数 @param $key @param int $expire @param int $incrby @return bool
[ "增加计数" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Limit.php#L36-L49
matyhtf/framework
libs/Swoole/Limit.php
Limit.exceed
function exceed($key, $limit) { $key = self::PREFIX . $key; $count = $this->redis->get($key); if (!empty($count) and $count > $limit) { return true; } else { return false; } }
php
function exceed($key, $limit) { $key = self::PREFIX . $key; $count = $this->redis->get($key); if (!empty($count) and $count > $limit) { return true; } else { return false; } }
[ "function", "exceed", "(", "$", "key", ",", "$", "limit", ")", "{", "$", "key", "=", "self", "::", "PREFIX", ".", "$", "key", ";", "$", "count", "=", "$", "this", "->", "redis", "->", "get", "(", "$", "key", ")", ";", "if", "(", "!", "empty",...
检查是否超过了频率限制,如果超过返回false,未超过返回true @param $key @param $limit @return bool
[ "检查是否超过了频率限制,如果超过返回false,未超过返回true" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Limit.php#L57-L70
matyhtf/framework
libs/Swoole/Limit.php
Limit.reset
function reset($key) { $key = self::PREFIX.$key; return $this->redis->del($key); }
php
function reset($key) { $key = self::PREFIX.$key; return $this->redis->del($key); }
[ "function", "reset", "(", "$", "key", ")", "{", "$", "key", "=", "self", "::", "PREFIX", ".", "$", "key", ";", "return", "$", "this", "->", "redis", "->", "del", "(", "$", "key", ")", ";", "}" ]
清除频率计数 @param $key @return bool
[ "清除频率计数" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Limit.php#L77-L81
matyhtf/framework
libs/Swoole/Model.php
Model.shard_table
function shard_table($id) { if (empty($this->_table_before_shard)) { $this->_table_before_shard = $this->table; } $table_id = intval($id / $this->tablesize); $this->table = $this->_table_before_shard . '_' . $table_id; }
php
function shard_table($id) { if (empty($this->_table_before_shard)) { $this->_table_before_shard = $this->table; } $table_id = intval($id / $this->tablesize); $this->table = $this->_table_before_shard . '_' . $table_id; }
[ "function", "shard_table", "(", "$", "id", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "_table_before_shard", ")", ")", "{", "$", "this", "->", "_table_before_shard", "=", "$", "this", "->", "table", ";", "}", "$", "table_id", "=", "intval", ...
按ID切分表 @param $id @return null
[ "按ID切分表" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Model.php#L63-L71
matyhtf/framework
libs/Swoole/Model.php
Model.get
public function get($object_id = 0, $where = '') { return new Record($object_id, $this->db, $this->table, $this->primary, $where, $this->select); }
php
public function get($object_id = 0, $where = '') { return new Record($object_id, $this->db, $this->table, $this->primary, $where, $this->select); }
[ "public", "function", "get", "(", "$", "object_id", "=", "0", ",", "$", "where", "=", "''", ")", "{", "return", "new", "Record", "(", "$", "object_id", ",", "$", "this", "->", "db", ",", "$", "this", "->", "table", ",", "$", "this", "->", "primar...
获取主键$primary_key为$object_id的一条记录对象(Record Object) 如果参数为空的话,则返回一条空白的Record,可以赋值,产生一条新的记录 @param $object_id @param $where @return Record Object
[ "获取主键$primary_key为$object_id的一条记录对象", "(", "Record", "Object", ")", "如果参数为空的话,则返回一条空白的Record,可以赋值,产生一条新的记录" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Model.php#L80-L83
matyhtf/framework
libs/Swoole/Model.php
Model.gets
public function gets($params, &$pager=null) { if (empty($params)) { throw new \Exception("no params."); } $selectdb = new SelectDB($this->db); $selectdb->from($this->table); $selectdb->primary = $this->primary; $selectdb->select($this->select); if (!isset($params['order'])) { $params['order']...
php
public function gets($params, &$pager=null) { if (empty($params)) { throw new \Exception("no params."); } $selectdb = new SelectDB($this->db); $selectdb->from($this->table); $selectdb->primary = $this->primary; $selectdb->select($this->select); if (!isset($params['order'])) { $params['order']...
[ "public", "function", "gets", "(", "$", "params", ",", "&", "$", "pager", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "params", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "\"no params.\"", ")", ";", "}", "$", "selectdb", "=", ...
获取表的一段数据,查询的参数由$params指定 @param $params @param $pager Pager @throws \Exception @return array
[ "获取表的一段数据,查询的参数由$params指定" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Model.php#L92-L117
matyhtf/framework
libs/Swoole/Model.php
Model.put
public function put($data) { if (empty($data) or !is_array($data)) { return false; } if ($this->db->insert($data, $this->table)) { $lastInsertId = $this->db->lastInsertId(); if ($lastInsertId == 0) { return true;...
php
public function put($data) { if (empty($data) or !is_array($data)) { return false; } if ($this->db->insert($data, $this->table)) { $lastInsertId = $this->db->lastInsertId(); if ($lastInsertId == 0) { return true;...
[ "public", "function", "put", "(", "$", "data", ")", "{", "if", "(", "empty", "(", "$", "data", ")", "or", "!", "is_array", "(", "$", "data", ")", ")", "{", "return", "false", ";", "}", "if", "(", "$", "this", "->", "db", "->", "insert", "(", ...
插入一条新的记录到表 @param $data array 必须是键值(表的字段对应值)对应 @return int
[ "插入一条新的记录到表" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Model.php#L124-L146
matyhtf/framework
libs/Swoole/Model.php
Model.puts
public function puts(array $fields, array $data) { $c = count($data); if ($c <= 0 or count($fields) <= 0) { return false; } return $this->db->insertBatch($fields, $data, $this->table); }
php
public function puts(array $fields, array $data) { $c = count($data); if ($c <= 0 or count($fields) <= 0) { return false; } return $this->db->insertBatch($fields, $data, $this->table); }
[ "public", "function", "puts", "(", "array", "$", "fields", ",", "array", "$", "data", ")", "{", "$", "c", "=", "count", "(", "$", "data", ")", ";", "if", "(", "$", "c", "<=", "0", "or", "count", "(", "$", "fields", ")", "<=", "0", ")", "{", ...
批量插入数据 @param array $fields @param array $data @return bool
[ "批量插入数据" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Model.php#L154-L163
matyhtf/framework
libs/Swoole/Model.php
Model.set
public function set($id, $data, $where = '') { if (empty($where)) { $where = $this->primary; } return $this->db->update($id, $data, $this->table, $where); }
php
public function set($id, $data, $where = '') { if (empty($where)) { $where = $this->primary; } return $this->db->update($id, $data, $this->table, $where); }
[ "public", "function", "set", "(", "$", "id", ",", "$", "data", ",", "$", "where", "=", "''", ")", "{", "if", "(", "empty", "(", "$", "where", ")", ")", "{", "$", "where", "=", "$", "this", "->", "primary", ";", "}", "return", "$", "this", "->...
更新ID为$id的记录,值为$data关联数组 @param $id @param $data @param $where string 指定匹配字段,默认为主键 @return bool
[ "更新ID为$id的记录", "值为$data关联数组" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Model.php#L172-L179
matyhtf/framework
libs/Swoole/Model.php
Model.sets
public function sets($data, $params) { if (empty($params)) { throw new \Exception("Model sets params is empty!"); } $selectdb = new SelectDB($this->db); $selectdb->from($this->table); $selectdb->put($params); return $selectdb->update($data); }
php
public function sets($data, $params) { if (empty($params)) { throw new \Exception("Model sets params is empty!"); } $selectdb = new SelectDB($this->db); $selectdb->from($this->table); $selectdb->put($params); return $selectdb->update($data); }
[ "public", "function", "sets", "(", "$", "data", ",", "$", "params", ")", "{", "if", "(", "empty", "(", "$", "params", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "\"Model sets params is empty!\"", ")", ";", "}", "$", "selectdb", "=", "new", ...
更新一组数据 @param array $data 更新的数据 @param array $params update的参数列表 @return bool @throws \Exception
[ "更新一组数据" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Model.php#L188-L198
matyhtf/framework
libs/Swoole/Model.php
Model.del
public function del($id, $where=null) { if ($where == null) { $where = $this->primary; } return $this->db->delete($id, $this->table, $where); }
php
public function del($id, $where=null) { if ($where == null) { $where = $this->primary; } return $this->db->delete($id, $this->table, $where); }
[ "public", "function", "del", "(", "$", "id", ",", "$", "where", "=", "null", ")", "{", "if", "(", "$", "where", "==", "null", ")", "{", "$", "where", "=", "$", "this", "->", "primary", ";", "}", "return", "$", "this", "->", "db", "->", "delete"...
删除一条数据主键为$id的记录, @param $id @param $where string 指定匹配字段,默认为主键 @return true/false
[ "删除一条数据主键为$id的记录," ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Model.php#L206-L213
matyhtf/framework
libs/Swoole/Model.php
Model.dels
public function dels($params) { if (empty($params)) { throw new \Exception("Model dels params is empty!"); } $selectdb = new SelectDB($this->db); $selectdb->from($this->table); $selectdb->put($params); $selectdb->delete(); return true; }
php
public function dels($params) { if (empty($params)) { throw new \Exception("Model dels params is empty!"); } $selectdb = new SelectDB($this->db); $selectdb->from($this->table); $selectdb->put($params); $selectdb->delete(); return true; }
[ "public", "function", "dels", "(", "$", "params", ")", "{", "if", "(", "empty", "(", "$", "params", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "\"Model dels params is empty!\"", ")", ";", "}", "$", "selectdb", "=", "new", "SelectDB", "(", "...
删除一条数据包含多个参数 @param $params @return bool @throws \Exception
[ "删除一条数据包含多个参数" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Model.php#L221-L232
matyhtf/framework
libs/Swoole/Model.php
Model.count
public function count($params) { $selectdb = new SelectDB($this->db); $selectdb->from($this->table); $selectdb->put($params); return $selectdb->count(); }
php
public function count($params) { $selectdb = new SelectDB($this->db); $selectdb->from($this->table); $selectdb->put($params); return $selectdb->count(); }
[ "public", "function", "count", "(", "$", "params", ")", "{", "$", "selectdb", "=", "new", "SelectDB", "(", "$", "this", "->", "db", ")", ";", "$", "selectdb", "->", "from", "(", "$", "this", "->", "table", ")", ";", "$", "selectdb", "->", "put", ...
返回符合条件的记录数 @param array $params @return true/false
[ "返回符合条件的记录数" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Model.php#L239-L245
matyhtf/framework
libs/Swoole/Model.php
Model.all
public function all() { return new RecordSet($this->db, $this->table, $this->primary, $this->select); }
php
public function all() { return new RecordSet($this->db, $this->table, $this->primary, $this->select); }
[ "public", "function", "all", "(", ")", "{", "return", "new", "RecordSet", "(", "$", "this", "->", "db", ",", "$", "this", "->", "table", ",", "$", "this", "->", "primary", ",", "$", "this", "->", "select", ")", ";", "}" ]
获取到所有表记录的接口,通过这个接口可以访问到数据库的记录 @return RecordSet Object (这是一个接口,不包含实际的数据)
[ "获取到所有表记录的接口,通过这个接口可以访问到数据库的记录" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Model.php#L251-L254
matyhtf/framework
libs/Swoole/Model.php
Model.getList
function getList(&$params,$get='data') { $selectdb = new SelectDB($this->db); $selectdb->from($this->table); $selectdb->select($this->select); $selectdb->limit(isset($params['row']) ? $params['row'] : 10); unset($params['row']); $selectdb->order(isset($params['order']) ? $params['order'] : $this->primary ....
php
function getList(&$params,$get='data') { $selectdb = new SelectDB($this->db); $selectdb->from($this->table); $selectdb->select($this->select); $selectdb->limit(isset($params['row']) ? $params['row'] : 10); unset($params['row']); $selectdb->order(isset($params['order']) ? $params['order'] : $this->primary ....
[ "function", "getList", "(", "&", "$", "params", ",", "$", "get", "=", "'data'", ")", "{", "$", "selectdb", "=", "new", "SelectDB", "(", "$", "this", "->", "db", ")", ";", "$", "selectdb", "->", "from", "(", "$", "this", "->", "table", ")", ";", ...
获取一个数据列表,功能类似于gets,此方法仅用于SiaoCMS,不作为同样类库的方法 @param $params @param $get @return array
[ "获取一个数据列表,功能类似于gets,此方法仅用于SiaoCMS,不作为同样类库的方法" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Model.php#L286-L325
matyhtf/framework
libs/Swoole/Model.php
Model.getMap
function getMap($gets, $field = null) { $list = $this->gets($gets); $new = array(); foreach ($list as $li) { if (empty($field)) { $new[$li[$this->primary]] = $li; } else { $new[$li[$this->primary...
php
function getMap($gets, $field = null) { $list = $this->gets($gets); $new = array(); foreach ($list as $li) { if (empty($field)) { $new[$li[$this->primary]] = $li; } else { $new[$li[$this->primary...
[ "function", "getMap", "(", "$", "gets", ",", "$", "field", "=", "null", ")", "{", "$", "list", "=", "$", "this", "->", "gets", "(", "$", "gets", ")", ";", "$", "new", "=", "array", "(", ")", ";", "foreach", "(", "$", "list", "as", "$", "li", ...
获取一个键值对应的结构,键为表记录主键的值,值为记录数据或者其中一个字段的值 @param $gets @param $field @return array
[ "获取一个键值对应的结构,键为表记录主键的值,值为记录数据或者其中一个字段的值" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Model.php#L333-L349
matyhtf/framework
libs/Swoole/Model.php
Model.getTree
function getTree($gets,$category='fid',$order='id desc') { $gets['order'] = $category . ',' . $order; $list = $this->gets($gets); foreach ($list as $li) { if ($li[$category] == 0) { $new[$li[$this->primary]] = $li; } else { $new[$li[$category]]['child'][$li[$this->primary]] = $li; } ...
php
function getTree($gets,$category='fid',$order='id desc') { $gets['order'] = $category . ',' . $order; $list = $this->gets($gets); foreach ($list as $li) { if ($li[$category] == 0) { $new[$li[$this->primary]] = $li; } else { $new[$li[$category]]['child'][$li[$this->primary]] = $li; } ...
[ "function", "getTree", "(", "$", "gets", ",", "$", "category", "=", "'fid'", ",", "$", "order", "=", "'id desc'", ")", "{", "$", "gets", "[", "'order'", "]", "=", "$", "category", ".", "','", ".", "$", "order", ";", "$", "list", "=", "$", "this",...
获取一个2层的树状结构 @param $gets @param $category @param $order @return unknown_type
[ "获取一个2层的树状结构" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Model.php#L358-L374
matyhtf/framework
libs/Swoole/Model.php
Model.existsTable
function existsTable() { $data = $this->db->query("show tables like '{$this->table}'")->fetch(); if (empty($data)) { return false; } else { return true; } }
php
function existsTable() { $data = $this->db->query("show tables like '{$this->table}'")->fetch(); if (empty($data)) { return false; } else { return true; } }
[ "function", "existsTable", "(", ")", "{", "$", "data", "=", "$", "this", "->", "db", "->", "query", "(", "\"show tables like '{$this->table}'\"", ")", "->", "fetch", "(", ")", ";", "if", "(", "empty", "(", "$", "data", ")", ")", "{", "return", "false",...
检测表是否存在
[ "检测表是否存在" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Model.php#L397-L408
matyhtf/framework
libs/Swoole/Model.php
Model.getForm
function getForm($set_id = 0) { $this->_form_(); //传入ID,修改表单 if ($set_id) { $data = $this->get((int)$set_id)->get(); foreach ($this->_form as $k => &$f) { $f['value'] = $data[$k]; } if (method_exists($this, "_set_")) { $this->_set_(); } if ($this->_form_secret) { Form::s...
php
function getForm($set_id = 0) { $this->_form_(); //传入ID,修改表单 if ($set_id) { $data = $this->get((int)$set_id)->get(); foreach ($this->_form as $k => &$f) { $f['value'] = $data[$k]; } if (method_exists($this, "_set_")) { $this->_set_(); } if ($this->_form_secret) { Form::s...
[ "function", "getForm", "(", "$", "set_id", "=", "0", ")", "{", "$", "this", "->", "_form_", "(", ")", ";", "//传入ID,修改表单", "if", "(", "$", "set_id", ")", "{", "$", "data", "=", "$", "this", "->", "get", "(", "(", "int", ")", "$", "set_id", ")", ...
自动生成表单 @param $set_id @return unknown_type
[ "自动生成表单" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Model.php#L425-L456
matyhtf/framework
libs/Swoole/View.php
View.assign
public function assign($name, $value = '') { if (is_array($name)) { $this->_var = array_merge($this->_var, $name); } elseif (is_object($name)) { foreach ($name as $key => $val) { $this->_var[$key] = $val; } ...
php
public function assign($name, $value = '') { if (is_array($name)) { $this->_var = array_merge($this->_var, $name); } elseif (is_object($name)) { foreach ($name as $key => $val) { $this->_var[$key] = $val; } ...
[ "public", "function", "assign", "(", "$", "name", ",", "$", "value", "=", "''", ")", "{", "if", "(", "is_array", "(", "$", "name", ")", ")", "{", "$", "this", "->", "_var", "=", "array_merge", "(", "$", "this", "->", "_var", ",", "$", "name", "...
+---------------------------------------------------------- 模板变量赋值 +---------------------------------------------------------- @access public +---------------------------------------------------------- @param mixed $name @param mixed $value +----------------------------------------------------------
[ "+", "----------------------------------------------------------", "模板变量赋值", "+", "----------------------------------------------------------" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/View.php#L37-L54
matyhtf/framework
libs/Swoole/View.php
View.trace
public function trace($title, $value = '') { if (is_array($title)) { $this->trace = array_merge($this->trace, $title); } else { $this->trace[$title] = $value; } }
php
public function trace($title, $value = '') { if (is_array($title)) { $this->trace = array_merge($this->trace, $title); } else { $this->trace[$title] = $value; } }
[ "public", "function", "trace", "(", "$", "title", ",", "$", "value", "=", "''", ")", "{", "if", "(", "is_array", "(", "$", "title", ")", ")", "{", "$", "this", "->", "trace", "=", "array_merge", "(", "$", "this", "->", "trace", ",", "$", "title",...
+---------------------------------------------------------- Trace变量赋值 +---------------------------------------------------------- @access public +---------------------------------------------------------- @param mixed $name @param mixed $value +----------------------------------------------------------
[ "+", "----------------------------------------------------------", "Trace变量赋值", "+", "----------------------------------------------------------" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/View.php#L66-L76
matyhtf/framework
libs/Swoole/View.php
View.get
public function get($name) { if (isset($this->_var[$name])) { return $this->_var[$name]; } else { return false; } }
php
public function get($name) { if (isset($this->_var[$name])) { return $this->_var[$name]; } else { return false; } }
[ "public", "function", "get", "(", "$", "name", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "_var", "[", "$", "name", "]", ")", ")", "{", "return", "$", "this", "->", "_var", "[", "$", "name", "]", ";", "}", "else", "{", "return", "f...
+---------------------------------------------------------- 取得模板变量的值 +---------------------------------------------------------- @access public +---------------------------------------------------------- @param string $name +---------------------------------------------------------- @return mixed +---------------------...
[ "+", "----------------------------------------------------------", "取得模板变量的值", "+", "----------------------------------------------------------" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/View.php#L89-L99
matyhtf/framework
libs/Swoole/View.php
View.display
public function display($templateFile = '', $charset = '', $contentType = 'text/html') { $this->fetch($templateFile, $charset, $contentType, true); }
php
public function display($templateFile = '', $charset = '', $contentType = 'text/html') { $this->fetch($templateFile, $charset, $contentType, true); }
[ "public", "function", "display", "(", "$", "templateFile", "=", "''", ",", "$", "charset", "=", "''", ",", "$", "contentType", "=", "'text/html'", ")", "{", "$", "this", "->", "fetch", "(", "$", "templateFile", ",", "$", "charset", ",", "$", "contentTy...
+---------------------------------------------------------- 加载模板和页面输出 可以返回输出内容 +---------------------------------------------------------- @access public +---------------------------------------------------------- @param string $templateFile 模板文件名 留空为自动获取 @param string $charset 模板输出字符集 @param string $contentType 输出类型 +...
[ "+", "----------------------------------------------------------", "加载模板和页面输出", "可以返回输出内容", "+", "----------------------------------------------------------" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/View.php#L114-L117
matyhtf/framework
libs/Swoole/View.php
View.layout
public function layout($content, $charset = '', $contentType = 'text/html') { // 查找布局包含的页面 $find = preg_match_all('/<!-- layout::(.+?)::(.+?) -->/is', $content, $matches); if ($find) { for ($i = 0; $i < $find; $i++) { // 读取相关的页面模板替换布局单元 ...
php
public function layout($content, $charset = '', $contentType = 'text/html') { // 查找布局包含的页面 $find = preg_match_all('/<!-- layout::(.+?)::(.+?) -->/is', $content, $matches); if ($find) { for ($i = 0; $i < $find; $i++) { // 读取相关的页面模板替换布局单元 ...
[ "public", "function", "layout", "(", "$", "content", ",", "$", "charset", "=", "''", ",", "$", "contentType", "=", "'text/html'", ")", "{", "// 查找布局包含的页面", "$", "find", "=", "preg_match_all", "(", "'/<!-- layout::(.+?)::(.+?) -->/is'", ",", "$", "content", ","...
+---------------------------------------------------------- 输出布局模板 +---------------------------------------------------------- @access public +---------------------------------------------------------- @param string $charset 输出编码 @param string $contentType 输出类型 @param string $display 是否直接显示 +---------------------------...
[ "+", "----------------------------------------------------------", "输出布局模板", "+", "----------------------------------------------------------" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/View.php#L132-L171
matyhtf/framework
libs/Swoole/View.php
View.fetch
public function fetch($templateFile = '', $charset = '', $contentType = 'text/html', $display = false) { $GLOBALS['_viewStartTime'] = microtime(true); if (null === $templateFile) { // 使用null参数作为模版名直接返回不做任何输出 return; } if (empty($charset)) { ...
php
public function fetch($templateFile = '', $charset = '', $contentType = 'text/html', $display = false) { $GLOBALS['_viewStartTime'] = microtime(true); if (null === $templateFile) { // 使用null参数作为模版名直接返回不做任何输出 return; } if (empty($charset)) { ...
[ "public", "function", "fetch", "(", "$", "templateFile", "=", "''", ",", "$", "charset", "=", "''", ",", "$", "contentType", "=", "'text/html'", ",", "$", "display", "=", "false", ")", "{", "$", "GLOBALS", "[", "'_viewStartTime'", "]", "=", "microtime", ...
+---------------------------------------------------------- 加载模板和页面输出 +---------------------------------------------------------- @access public +---------------------------------------------------------- @param string $templateFile 模板文件名 留空为自动获取 @param string $charset 模板输出字符集 @param string $contentType 输出类型 @param str...
[ "+", "----------------------------------------------------------", "加载模板和页面输出", "+", "----------------------------------------------------------" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/View.php#L187-L214
matyhtf/framework
libs/Swoole/View.php
View.buildHtml
public function buildHtml($htmlfile = '', $templateFile = '', $charset = '', $contentType = 'text/html') { $content = $this->fetch($templateFile, $charset, $contentType); if (empty($htmlfile)) { $htmlfile = HTML_PATH . rtrim($_SERVER['PATH_INFO'], '/') . C('HTML_FILE_SUFFIX'); ...
php
public function buildHtml($htmlfile = '', $templateFile = '', $charset = '', $contentType = 'text/html') { $content = $this->fetch($templateFile, $charset, $contentType); if (empty($htmlfile)) { $htmlfile = HTML_PATH . rtrim($_SERVER['PATH_INFO'], '/') . C('HTML_FILE_SUFFIX'); ...
[ "public", "function", "buildHtml", "(", "$", "htmlfile", "=", "''", ",", "$", "templateFile", "=", "''", ",", "$", "charset", "=", "''", ",", "$", "contentType", "=", "'text/html'", ")", "{", "$", "content", "=", "$", "this", "->", "fetch", "(", "$",...
+---------------------------------------------------------- 创建静态页面 +---------------------------------------------------------- @access public +---------------------------------------------------------- @htmlfile 生成的静态文件名称 @param string $templateFile 指定要调用的模板文件 默认为空 由系统自动定位模板文件 @param string $charset 输出编码 @param string ...
[ "+", "----------------------------------------------------------", "创建静态页面", "+", "----------------------------------------------------------" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/View.php#L238-L256
matyhtf/framework
libs/Swoole/View.php
View.output
protected function output($content, $display) { if ($this->if_pagecache) { $pagecache = new Swoole_pageCache($this->cache_life); if ($pagecache->isCached()) { $pagecache->load(); } else { $pagecac...
php
protected function output($content, $display) { if ($this->if_pagecache) { $pagecache = new Swoole_pageCache($this->cache_life); if ($pagecache->isCached()) { $pagecache->load(); } else { $pagecac...
[ "protected", "function", "output", "(", "$", "content", ",", "$", "display", ")", "{", "if", "(", "$", "this", "->", "if_pagecache", ")", "{", "$", "pagecache", "=", "new", "Swoole_pageCache", "(", "$", "this", "->", "cache_life", ")", ";", "if", "(", ...
+---------------------------------------------------------- 输出模板 +---------------------------------------------------------- @access protected +---------------------------------------------------------- @param string $content 模板内容 @param boolean $display 是否直接显示 +---------------------------------------------------------...
[ "+", "----------------------------------------------------------", "输出模板", "+", "----------------------------------------------------------" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/View.php#L270-L299
matyhtf/framework
libs/Swoole/View.php
View.showTime
protected function showTime() { // 显示运行时间 $startTime = $this->swoole->env['runtime']['start']; $endTime = microtime(true); $total_run_time = number_format(($endTime - $startTime), 4); $showTime = '执行时间: ' . $total_run_time . 's '; $startMem = array_sum(explode(' ', $...
php
protected function showTime() { // 显示运行时间 $startTime = $this->swoole->env['runtime']['start']; $endTime = microtime(true); $total_run_time = number_format(($endTime - $startTime), 4); $showTime = '执行时间: ' . $total_run_time . 's '; $startMem = array_sum(explode(' ', $...
[ "protected", "function", "showTime", "(", ")", "{", "// 显示运行时间", "$", "startTime", "=", "$", "this", "->", "swoole", "->", "env", "[", "'runtime'", "]", "[", "'start'", "]", ";", "$", "endTime", "=", "microtime", "(", "true", ")", ";", "$", "total_run_...
+---------------------------------------------------------- 显示运行时间、数据库操作、缓存次数、内存使用信息 +---------------------------------------------------------- @access protected +---------------------------------------------------------- @return string +----------------------------------------------------------
[ "+", "----------------------------------------------------------", "显示运行时间、数据库操作、缓存次数、内存使用信息", "+", "----------------------------------------------------------" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/View.php#L325-L338
matyhtf/framework
libs/Swoole/View.php
View.showTrace
public function showTrace($detail = false) { // 显示页面Trace信息 读取Trace定义文件 // 定义格式 return array('当前页面'=>$_SERVER['PHP_SELF'],'通信协议'=>$_SERVER['SERVER_PROTOCOL'],...); $_trace = array(); // 系统默认显示信息 $this->trace('当前页面', $_SERVER['REQUEST_URI']); $this->trace('请求方法', $_SER...
php
public function showTrace($detail = false) { // 显示页面Trace信息 读取Trace定义文件 // 定义格式 return array('当前页面'=>$_SERVER['PHP_SELF'],'通信协议'=>$_SERVER['SERVER_PROTOCOL'],...); $_trace = array(); // 系统默认显示信息 $this->trace('当前页面', $_SERVER['REQUEST_URI']); $this->trace('请求方法', $_SER...
[ "public", "function", "showTrace", "(", "$", "detail", "=", "false", ")", "{", "// 显示页面Trace信息 读取Trace定义文件", "// 定义格式 return array('当前页面'=>$_SERVER['PHP_SELF'],'通信协议'=>$_SERVER['SERVER_PROTOCOL'],...);", "$", "_trace", "=", "array", "(", ")", ";", "// 系统默认显示信息", "$", "this"...
+---------------------------------------------------------- 显示页面Trace信息 +---------------------------------------------------------- @access protected +---------------------------------------------------------- @param string $showTime 运行时间信息 +----------------------------------------------------------
[ "+", "----------------------------------------------------------", "显示页面Trace信息", "+", "----------------------------------------------------------" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/View.php#L349-L392
matyhtf/framework
libs/Swoole/Auth.php
Auth.updateStatus
function updateStatus($set = null) { if (empty($set)) { $set = array( self::$lastlogin => date('Y-m-d H:i:s'), self::$lastip => \Swoole::$php->request->getClientIP() ); } return $this->db->update($this->user['id'], $set, $this->...
php
function updateStatus($set = null) { if (empty($set)) { $set = array( self::$lastlogin => date('Y-m-d H:i:s'), self::$lastip => \Swoole::$php->request->getClientIP() ); } return $this->db->update($this->user['id'], $set, $this->...
[ "function", "updateStatus", "(", "$", "set", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "set", ")", ")", "{", "$", "set", "=", "array", "(", "self", "::", "$", "lastlogin", "=>", "date", "(", "'Y-m-d H:i:s'", ")", ",", "self", "::", "$"...
更新用户信息 @param $set @return bool
[ "更新用户信息" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Auth.php#L81-L91
matyhtf/framework
libs/Swoole/Auth.php
Auth.login
function login($username, $password) { Cookie::set(self::$session_prefix . 'username', $username, time() + self::$cookie_life, '/'); $this->user = $this->db->query('select ' . $this->select . ' from ' . $this->login_table . " where " . self::$username . "='$username' limit 1")->fetch(); if (...
php
function login($username, $password) { Cookie::set(self::$session_prefix . 'username', $username, time() + self::$cookie_life, '/'); $this->user = $this->db->query('select ' . $this->select . ' from ' . $this->login_table . " where " . self::$username . "='$username' limit 1")->fetch(); if (...
[ "function", "login", "(", "$", "username", ",", "$", "password", ")", "{", "Cookie", "::", "set", "(", "self", "::", "$", "session_prefix", ".", "'username'", ",", "$", "username", ",", "time", "(", ")", "+", "self", "::", "$", "cookie_life", ",", "'...
登录 @param $username @param $password @return bool
[ "登录" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Auth.php#L123-L147
matyhtf/framework
libs/Swoole/Auth.php
Auth.isLogin
function isLogin() { if (isset($_SESSION[self::$session_prefix . 'isLogin']) and $_SESSION[self::$session_prefix . 'isLogin'] == 1) { return true; } return false; }
php
function isLogin() { if (isset($_SESSION[self::$session_prefix . 'isLogin']) and $_SESSION[self::$session_prefix . 'isLogin'] == 1) { return true; } return false; }
[ "function", "isLogin", "(", ")", "{", "if", "(", "isset", "(", "$", "_SESSION", "[", "self", "::", "$", "session_prefix", ".", "'isLogin'", "]", ")", "and", "$", "_SESSION", "[", "self", "::", "$", "session_prefix", ".", "'isLogin'", "]", "==", "1", ...
检查是否登录 @return bool
[ "检查是否登录" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Auth.php#L153-L160
matyhtf/framework
libs/Swoole/Auth.php
Auth.changePassword
function changePassword($uid, $old_pwd, $new_pwd) { $table = table($this->login_table, $this->login_db); $table->primary = self::$userid; $_res = $table->gets(array('select' => self::$username . ',' . self::$password, 'limit' => 1, self::$userid => $uid)); if (count($_res) < 1) ...
php
function changePassword($uid, $old_pwd, $new_pwd) { $table = table($this->login_table, $this->login_db); $table->primary = self::$userid; $_res = $table->gets(array('select' => self::$username . ',' . self::$password, 'limit' => 1, self::$userid => $uid)); if (count($_res) < 1) ...
[ "function", "changePassword", "(", "$", "uid", ",", "$", "old_pwd", ",", "$", "new_pwd", ")", "{", "$", "table", "=", "table", "(", "$", "this", "->", "login_table", ",", "$", "this", "->", "login_db", ")", ";", "$", "table", "->", "primary", "=", ...
修改密码 @param $uid @param $old_pwd @param $new_pwd @return bool @throws \Exception
[ "修改密码" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Auth.php#L170-L194
matyhtf/framework
libs/Swoole/Auth.php
Auth.logout
function logout() { /** * 启动Session */ if (!\Swoole::$php->session->isStart) { \Swoole::$php->session->start(); } /** * 如果设置为true,退出登录时,销毁所有Session */ if (self::$session_destroy) { $_SESSION = array()...
php
function logout() { /** * 启动Session */ if (!\Swoole::$php->session->isStart) { \Swoole::$php->session->start(); } /** * 如果设置为true,退出登录时,销毁所有Session */ if (self::$session_destroy) { $_SESSION = array()...
[ "function", "logout", "(", ")", "{", "/**\n * 启动Session\n */", "if", "(", "!", "\\", "Swoole", "::", "$", "php", "->", "session", "->", "isStart", ")", "{", "\\", "Swoole", "::", "$", "php", "->", "session", "->", "start", "(", ")", ";", ...
注销登录 @return bool
[ "注销登录" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Auth.php#L200-L228
matyhtf/framework
libs/Swoole/Auth.php
Auth.verifyPassword
public static function verifyPassword($username, $input_password, $real_password) { //使用PHP内置的password if (self::$password_hash == 'crypt') { if (!function_exists('password_verify')) { throw new \Exception("require password_verify function."); ...
php
public static function verifyPassword($username, $input_password, $real_password) { //使用PHP内置的password if (self::$password_hash == 'crypt') { if (!function_exists('password_verify')) { throw new \Exception("require password_verify function."); ...
[ "public", "static", "function", "verifyPassword", "(", "$", "username", ",", "$", "input_password", ",", "$", "real_password", ")", "{", "//使用PHP内置的password", "if", "(", "self", "::", "$", "password_hash", "==", "'crypt'", ")", "{", "if", "(", "!", "function...
验证密码 @param $username @param $input_password @param $real_password @return bool @throws \Exception
[ "验证密码" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Auth.php#L238-L254
matyhtf/framework
libs/Swoole/Auth.php
Auth.makePasswordHash
public static function makePasswordHash($username, $password) { //sha1 用户名+密码 if (self::$password_hash == 'sha1') { return sha1($username . $password); } //使用PHP内置的password elseif(self::$password_hash == 'crypt') { if (!function_exists(...
php
public static function makePasswordHash($username, $password) { //sha1 用户名+密码 if (self::$password_hash == 'sha1') { return sha1($username . $password); } //使用PHP内置的password elseif(self::$password_hash == 'crypt') { if (!function_exists(...
[ "public", "static", "function", "makePasswordHash", "(", "$", "username", ",", "$", "password", ")", "{", "//sha1 用户名+密码", "if", "(", "self", "::", "$", "password_hash", "==", "'sha1'", ")", "{", "return", "sha1", "(", "$", "username", ".", "$", "password"...
产生一个密码串,连接用户名和密码,并使用sha1产生散列 @param $username @param $password @throws \Exception @return string
[ "产生一个密码串,连接用户名和密码,并使用sha1产生散列" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Auth.php#L263-L297
matyhtf/framework
libs/Swoole/Auth.php
Auth.loginRequire
public static function loginRequire() { /** * 启动Session */ if (!\Swoole::$php->session->isStart) { \Swoole::$php->session->start(); } $user = \Swoole::$php->user; if (!$user->isLogin()) { if (strpos($_SERVER["REQUEST_U...
php
public static function loginRequire() { /** * 启动Session */ if (!\Swoole::$php->session->isStart) { \Swoole::$php->session->start(); } $user = \Swoole::$php->user; if (!$user->isLogin()) { if (strpos($_SERVER["REQUEST_U...
[ "public", "static", "function", "loginRequire", "(", ")", "{", "/**\n * 启动Session\n */", "if", "(", "!", "\\", "Swoole", "::", "$", "php", "->", "session", "->", "isStart", ")", "{", "\\", "Swoole", "::", "$", "php", "->", "session", "->", ...
验证登录 @return bool
[ "验证登录" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Auth.php#L303-L328
matyhtf/framework
libs/Swoole/Form.php
Form.autoform
static function autoform($form_array) { $forms = array(); foreach($form_array as $k=>$v) { //表单类型 $func = $v['type']; //表单值 $value = ''; if(isset($v['value'])) $value = $v['value']; unset($v['type'],$v['value']); if($func=='input' or $func=='password' or $func=='text' or $func=='htmltext...
php
static function autoform($form_array) { $forms = array(); foreach($form_array as $k=>$v) { //表单类型 $func = $v['type']; //表单值 $value = ''; if(isset($v['value'])) $value = $v['value']; unset($v['type'],$v['value']); if($func=='input' or $func=='password' or $func=='text' or $func=='htmltext...
[ "static", "function", "autoform", "(", "$", "form_array", ")", "{", "$", "forms", "=", "array", "(", ")", ";", "foreach", "(", "$", "form_array", "as", "$", "k", "=>", "$", "v", ")", "{", "//表单类型", "$", "func", "=", "$", "v", "[", "'type'", "]", ...
根据数组,生成表单 @param $form_array @return unknown_type
[ "根据数组,生成表单" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Form.php#L23-L53
matyhtf/framework
libs/Swoole/Form.php
Form.input_attr
static function input_attr(&$attr) { $str = " "; if(!empty($attr) && is_array($attr)) { foreach($attr as $key=>$value) { $str .= "$key=\"$value\" "; } } return $str; }
php
static function input_attr(&$attr) { $str = " "; if(!empty($attr) && is_array($attr)) { foreach($attr as $key=>$value) { $str .= "$key=\"$value\" "; } } return $str; }
[ "static", "function", "input_attr", "(", "&", "$", "attr", ")", "{", "$", "str", "=", "\" \"", ";", "if", "(", "!", "empty", "(", "$", "attr", ")", "&&", "is_array", "(", "$", "attr", ")", ")", "{", "foreach", "(", "$", "attr", "as", "$", "key"...
元素选项处理 @param $attr @return unknown_type
[ "元素选项处理" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Form.php#L143-L154
matyhtf/framework
libs/Swoole/Form.php
Form.select
static function select($name, $option, $default = null, $self = null, $attrArray = null, $add_help = true, $force = false) { $htmlStr = "<select name=\"$name\" id=\"$name\""; $htmlStr .= self::input_attr($attrArray) . ">\n"; if ($add_help) { if ($add_help === true) { $htmlStr ....
php
static function select($name, $option, $default = null, $self = null, $attrArray = null, $add_help = true, $force = false) { $htmlStr = "<select name=\"$name\" id=\"$name\""; $htmlStr .= self::input_attr($attrArray) . ">\n"; if ($add_help) { if ($add_help === true) { $htmlStr ....
[ "static", "function", "select", "(", "$", "name", ",", "$", "option", ",", "$", "default", "=", "null", ",", "$", "self", "=", "null", ",", "$", "attrArray", "=", "null", ",", "$", "add_help", "=", "true", ",", "$", "force", "=", "false", ")", "{...
下拉选择菜单 $name 此select 的 name 标签 $array 要制作select 的数 $default 如果要设定默认选择哪个数据 就在此填入默认的数据的值 $self 设置为true,option的值等于$value $attrArray html标签的熟悉 就是这个select的属性标签 例如 class="x1" $add_help 增加一个值为空的 请选择 项 $force 强类型判断
[ "下拉选择菜单", "$name", "此select", "的", "name", "标签", "$array", "要制作select", "的数", "$default", "如果要设定默认选择哪个数据", "就在此填入默认的数据的值", "$self", "设置为true,option的值等于$value", "$attrArray", "html标签的熟悉", "就是这个select的属性标签", "例如", "class", "=", "x1", "$add_help", "增加一个值为空的", "请选择", "项",...
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Form.php#L165-L193
matyhtf/framework
libs/Swoole/Form.php
Form.muti_select
static function muti_select($name,$option,$default=array(),$self=null,$attrArray=null,$add_help=true) { $htmlStr = "<select name=\"$name\" id=\"$name\""; $htmlStr .= self::input_attr($attrArray) . ">\n"; if($add_help) { if($add_help===true) $htmlStr .= "<option value=\"\">".self::$default_help_option."...
php
static function muti_select($name,$option,$default=array(),$self=null,$attrArray=null,$add_help=true) { $htmlStr = "<select name=\"$name\" id=\"$name\""; $htmlStr .= self::input_attr($attrArray) . ">\n"; if($add_help) { if($add_help===true) $htmlStr .= "<option value=\"\">".self::$default_help_option."...
[ "static", "function", "muti_select", "(", "$", "name", ",", "$", "option", ",", "$", "default", "=", "array", "(", ")", ",", "$", "self", "=", "null", ",", "$", "attrArray", "=", "null", ",", "$", "add_help", "=", "true", ")", "{", "$", "htmlStr", ...
多选下拉选择菜单 $name 此select 的 name 标签 $array 要制作select 的数 $default 如果要设定默认选择哪个数据 就在此填入默认的数据的值 $self 设置为ture,option的值等于$value $attrArray html标签的熟悉 就是这个select的属性标签 例如 class="x1" $add_help 增加一个值为空的 请选择 项
[ "多选下拉选择菜单", "$name", "此select", "的", "name", "标签", "$array", "要制作select", "的数", "$default", "如果要设定默认选择哪个数据", "就在此填入默认的数据的值", "$self", "设置为ture,option的值等于$value", "$attrArray", "html标签的熟悉", "就是这个select的属性标签", "例如", "class", "=", "x1", "$add_help", "增加一个值为空的", "请选择", "项...
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Form.php#L204-L230
matyhtf/framework
libs/Swoole/Form.php
Form.radio
static function radio($name, $option, $default = null, $self = false, $attrArray = null, $label_class = '') { $htmlStr = ""; $attrStr = self::input_attr($attrArray); foreach($option as $key => $value) { if($self) $key=$value; if ($key == $default) { $htmlStr .= "<label class='$label_class'><in...
php
static function radio($name, $option, $default = null, $self = false, $attrArray = null, $label_class = '') { $htmlStr = ""; $attrStr = self::input_attr($attrArray); foreach($option as $key => $value) { if($self) $key=$value; if ($key == $default) { $htmlStr .= "<label class='$label_class'><in...
[ "static", "function", "radio", "(", "$", "name", ",", "$", "option", ",", "$", "default", "=", "null", ",", "$", "self", "=", "false", ",", "$", "attrArray", "=", "null", ",", "$", "label_class", "=", "''", ")", "{", "$", "htmlStr", "=", "\"\"", ...
单选按钮 $name 此radio 的 name 标签 $array 要制作radio 的数 $default 如果要设定默认选择哪个数据 就在此填入默认的数据的值 $self 设置为ture,option的值等于$value $attrArray html的属性 例如 class="x1"
[ "单选按钮", "$name", "此radio", "的", "name", "标签", "$array", "要制作radio", "的数", "$default", "如果要设定默认选择哪个数据", "就在此填入默认的数据的值", "$self", "设置为ture,option的值等于$value", "$attrArray", "html的属性", "例如", "class", "=", "x1" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Form.php#L240-L258
matyhtf/framework
libs/Swoole/Form.php
Form.checkbox
static function checkbox($name, $option, $default = null, $self = false, $attrArray = null, $label_class = '') { $htmlStr = ""; $attrStr = self::input_attr($attrArray); $default = array_flip(explode(self::$checkbox_value_split, $default)); foreach ($option as $key => $value) { if ($self) { $key = ...
php
static function checkbox($name, $option, $default = null, $self = false, $attrArray = null, $label_class = '') { $htmlStr = ""; $attrStr = self::input_attr($attrArray); $default = array_flip(explode(self::$checkbox_value_split, $default)); foreach ($option as $key => $value) { if ($self) { $key = ...
[ "static", "function", "checkbox", "(", "$", "name", ",", "$", "option", ",", "$", "default", "=", "null", ",", "$", "self", "=", "false", ",", "$", "attrArray", "=", "null", ",", "$", "label_class", "=", "''", ")", "{", "$", "htmlStr", "=", "\"\"",...
多选按钮 @param string $name 此radio 的 name 标签 @param array $option 要制作radio 的数 @param string $default 如果要设定默认选择哪个数据 就在此填入默认的数据的值 @param bool $self 设置为ture,option的值等于$value @param array $attrArray html的属性 例如 class="x1" @param string $label_class @return string
[ "多选按钮" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Form.php#L269-L297
matyhtf/framework
libs/Swoole/Form.php
Form.upload
static function upload($name, $value = '', $attrArray = null) { $attrStr = self::input_attr($attrArray); $form = ''; if(!empty($value)) $form = " <a href='$value' target='_blank'>查看文件</a><br />\n重新上传"; return $form."<input type='file' name='$name' id='{$name}' {$attrStr} />"; ...
php
static function upload($name, $value = '', $attrArray = null) { $attrStr = self::input_attr($attrArray); $form = ''; if(!empty($value)) $form = " <a href='$value' target='_blank'>查看文件</a><br />\n重新上传"; return $form."<input type='file' name='$name' id='{$name}' {$attrStr} />"; ...
[ "static", "function", "upload", "(", "$", "name", ",", "$", "value", "=", "''", ",", "$", "attrArray", "=", "null", ")", "{", "$", "attrStr", "=", "self", "::", "input_attr", "(", "$", "attrArray", ")", ";", "$", "form", "=", "''", ";", "if", "("...
文件上传表单 @param $name 表单名称 @param $value 值 @param $attrArray html的属性 例如 class="x1" @return unknown_type
[ "文件上传表单" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Form.php#L306-L313
matyhtf/framework
libs/Swoole/Form.php
Form.button
static function button($name,$value='',$attrArray=null) { if(empty($attrArray['type'])) $attrArray['type'] = 'button'; $attrStr = self::input_attr($attrArray); return "<input name='{$name}' id='{$name}' value='{$value}' {$attrStr} />"; }
php
static function button($name,$value='',$attrArray=null) { if(empty($attrArray['type'])) $attrArray['type'] = 'button'; $attrStr = self::input_attr($attrArray); return "<input name='{$name}' id='{$name}' value='{$value}' {$attrStr} />"; }
[ "static", "function", "button", "(", "$", "name", ",", "$", "value", "=", "''", ",", "$", "attrArray", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "attrArray", "[", "'type'", "]", ")", ")", "$", "attrArray", "[", "'type'", "]", "=", "'bu...
按钮 @param $name @param $value @param $attrArray @return unknown_type
[ "按钮" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Form.php#L333-L338
matyhtf/framework
libs/Swoole/Form.php
Form.text
static function text($name,$value='',$attrArray=null) { if(!isset($attrArray['cols'])) $attrArray['cols'] = 60; if(!isset($attrArray['rows'])) $attrArray['rows'] = 3; $attrStr = self::input_attr($attrArray); $forms = "<textarea name='{$name}' id='{$name}' $attrStr>$value</textarea>"; return $forms; }
php
static function text($name,$value='',$attrArray=null) { if(!isset($attrArray['cols'])) $attrArray['cols'] = 60; if(!isset($attrArray['rows'])) $attrArray['rows'] = 3; $attrStr = self::input_attr($attrArray); $forms = "<textarea name='{$name}' id='{$name}' $attrStr>$value</textarea>"; return $forms; }
[ "static", "function", "text", "(", "$", "name", ",", "$", "value", "=", "''", ",", "$", "attrArray", "=", "null", ")", "{", "if", "(", "!", "isset", "(", "$", "attrArray", "[", "'cols'", "]", ")", ")", "$", "attrArray", "[", "'cols'", "]", "=", ...
多行文本输入框 @param $name @param $value @param $attrArray @return string
[ "多行文本输入框" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Form.php#L358-L365
matyhtf/framework
libs/Swoole/Form.php
Form.head
static function head($form_name,$method='post',$action='',$if_upload=false,$attrArray=null) { if($if_upload) $attrArray['enctype'] = "multipart/form-data"; $attrStr = self::input_attr($attrArray); return "action='$action' method='$method' name='$form_name' id='$form_name' $attrStr"; }
php
static function head($form_name,$method='post',$action='',$if_upload=false,$attrArray=null) { if($if_upload) $attrArray['enctype'] = "multipart/form-data"; $attrStr = self::input_attr($attrArray); return "action='$action' method='$method' name='$form_name' id='$form_name' $attrStr"; }
[ "static", "function", "head", "(", "$", "form_name", ",", "$", "method", "=", "'post'", ",", "$", "action", "=", "''", ",", "$", "if_upload", "=", "false", ",", "$", "attrArray", "=", "null", ")", "{", "if", "(", "$", "if_upload", ")", "$", "attrAr...
表单头部 @param $form_name @param $method @param $action @param $if_upload @param $attrArray @return string
[ "表单头部" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Form.php#L389-L394
matyhtf/framework
libs/Swoole/Form.php
Form.secret
static function secret($page_name = '', $length = 32, $return = false) { $secret = uniqid(RandomKey::string($length)); if ($return) { return $secret; } else { $k = 'form_' . $page_name; setcookie($k, $secret, 0, '/'); if...
php
static function secret($page_name = '', $length = 32, $return = false) { $secret = uniqid(RandomKey::string($length)); if ($return) { return $secret; } else { $k = 'form_' . $page_name; setcookie($k, $secret, 0, '/'); if...
[ "static", "function", "secret", "(", "$", "page_name", "=", "''", ",", "$", "length", "=", "32", ",", "$", "return", "=", "false", ")", "{", "$", "secret", "=", "uniqid", "(", "RandomKey", "::", "string", "(", "$", "length", ")", ")", ";", "if", ...
设置Form Secret防止,非当前页面提交数据 @param $page_name @param $return @return string
[ "设置Form", "Secret防止,非当前页面提交数据" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Form.php#L401-L418
matyhtf/framework
libs/Swoole/Database/MySQLi.php
MySQLi.connect
function connect($_host = null, $user = null, $password = null, $database = null, $port = null, $socket = null) { $db_config = &$this->config; $host = $db_config['host']; if (!empty($db_config['persistent'])) { $host = 'p:' . $host; } if (isset($db_config[...
php
function connect($_host = null, $user = null, $password = null, $database = null, $port = null, $socket = null) { $db_config = &$this->config; $host = $db_config['host']; if (!empty($db_config['persistent'])) { $host = 'p:' . $host; } if (isset($db_config[...
[ "function", "connect", "(", "$", "_host", "=", "null", ",", "$", "user", "=", "null", ",", "$", "password", "=", "null", ",", "$", "database", "=", "null", ",", "$", "port", "=", "null", ",", "$", "socket", "=", "null", ")", "{", "$", "db_config"...
参数为了兼容parent类,代码不会使用传入的参数作为配置 @param null $_host @param null $user @param null $password @param null $database @param null $port @param null $socket @return bool
[ "参数为了兼容parent类,代码不会使用传入的参数作为配置" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Database/MySQLi.php#L52-L89
matyhtf/framework
libs/Swoole/Database/MySQLi.php
MySQLi.errorMessage
protected function errorMessage($sql) { $msg = $this->mysqli->error . "<hr />$sql<hr />\n"; $msg .= "Server: {$this->config['host']}:{$this->config['port']}. <br/>\n"; if ($this->mysqli->connect_errno) { $msg .= "ConnectError[{$this->mysqli->connect_errno}]: {$this->mysql...
php
protected function errorMessage($sql) { $msg = $this->mysqli->error . "<hr />$sql<hr />\n"; $msg .= "Server: {$this->config['host']}:{$this->config['port']}. <br/>\n"; if ($this->mysqli->connect_errno) { $msg .= "ConnectError[{$this->mysqli->connect_errno}]: {$this->mysql...
[ "protected", "function", "errorMessage", "(", "$", "sql", ")", "{", "$", "msg", "=", "$", "this", "->", "mysqli", "->", "error", ".", "\"<hr />$sql<hr />\\n\"", ";", "$", "msg", ".=", "\"Server: {$this->config['host']}:{$this->config['port']}. <br/>\\n\"", ";", "if"...
SQL错误信息 @param $sql @return string
[ "SQL错误信息" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Database/MySQLi.php#L106-L117
matyhtf/framework
libs/Swoole/Database/MySQLi.php
MySQLi.query
function query($sql, $resultmode = null) { $result = $this->tryReconnect(array($this->mysqli, 'query'), array($sql, $resultmode)); if (!$result) { trigger_error(__CLASS__ . " SQL Error:" . $this->errorMessage($sql), E_USER_WARNING); return false; } if...
php
function query($sql, $resultmode = null) { $result = $this->tryReconnect(array($this->mysqli, 'query'), array($sql, $resultmode)); if (!$result) { trigger_error(__CLASS__ . " SQL Error:" . $this->errorMessage($sql), E_USER_WARNING); return false; } if...
[ "function", "query", "(", "$", "sql", ",", "$", "resultmode", "=", "null", ")", "{", "$", "result", "=", "$", "this", "->", "tryReconnect", "(", "array", "(", "$", "this", "->", "mysqli", ",", "'query'", ")", ",", "array", "(", "$", "sql", ",", "...
执行一个SQL语句 @param string $sql 执行的SQL语句 @param int $resultmode @return MySQLiRecord | false
[ "执行一个SQL语句" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Database/MySQLi.php#L153-L167
matyhtf/framework
libs/Swoole/Database/MySQLi.php
MySQLi.multi_query
function multi_query($sql) { $result = $this->tryReconnect(array('parent', 'multi_query'), array($sql)); if (!$result) { Swoole\Error::info(__CLASS__ . " SQL Error", $this->errorMessage($sql)); return false; } $result = call_user_func_array(array('par...
php
function multi_query($sql) { $result = $this->tryReconnect(array('parent', 'multi_query'), array($sql)); if (!$result) { Swoole\Error::info(__CLASS__ . " SQL Error", $this->errorMessage($sql)); return false; } $result = call_user_func_array(array('par...
[ "function", "multi_query", "(", "$", "sql", ")", "{", "$", "result", "=", "$", "this", "->", "tryReconnect", "(", "array", "(", "'parent'", ",", "'multi_query'", ")", ",", "array", "(", "$", "sql", ")", ")", ";", "if", "(", "!", "$", "result", ")",...
执行多个SQL语句 @param string $sql 执行的SQL语句 @return MySQLiRecord | false
[ "执行多个SQL语句" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Database/MySQLi.php#L174-L204
matyhtf/framework
libs/Swoole/Database/MySQLi.php
MySQLi.queryAsync
function queryAsync($sql) { $result = $this->tryReconnect(array('parent', 'query'), array($sql, MYSQLI_ASYNC)); if (!$result) { Swoole\Error::info(__CLASS__." SQL Error", $this->errorMessage($sql)); return false; } return $result; }
php
function queryAsync($sql) { $result = $this->tryReconnect(array('parent', 'query'), array($sql, MYSQLI_ASYNC)); if (!$result) { Swoole\Error::info(__CLASS__." SQL Error", $this->errorMessage($sql)); return false; } return $result; }
[ "function", "queryAsync", "(", "$", "sql", ")", "{", "$", "result", "=", "$", "this", "->", "tryReconnect", "(", "array", "(", "'parent'", ",", "'query'", ")", ",", "array", "(", "$", "sql", ",", "MYSQLI_ASYNC", ")", ")", ";", "if", "(", "!", "$", ...
异步SQL @param $sql @return bool|\mysqli_result
[ "异步SQL" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Database/MySQLi.php#L211-L220
matyhtf/framework
libs/Swoole/Encrypter.php
Encrypter.encrypt
public function encrypt($value, $serialize = true) { $iv = self::randomBytes(openssl_cipher_iv_length($this->cipher)); // First we will encrypt the value using OpenSSL. After this is encrypted we // will proceed to calculating a MAC for the encrypted value so that this // value can ...
php
public function encrypt($value, $serialize = true) { $iv = self::randomBytes(openssl_cipher_iv_length($this->cipher)); // First we will encrypt the value using OpenSSL. After this is encrypted we // will proceed to calculating a MAC for the encrypted value so that this // value can ...
[ "public", "function", "encrypt", "(", "$", "value", ",", "$", "serialize", "=", "true", ")", "{", "$", "iv", "=", "self", "::", "randomBytes", "(", "openssl_cipher_iv_length", "(", "$", "this", "->", "cipher", ")", ")", ";", "// First we will encrypt the val...
Encrypt the given value. @param mixed $value @param bool $serialize @return string @throws \Exception
[ "Encrypt", "the", "given", "value", "." ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Encrypter.php#L77-L105
matyhtf/framework
libs/Swoole/Encrypter.php
Encrypter.decrypt
public function decrypt($payload, $unserialize = true) { $payload = $this->getJsonPayload($payload); $iv = base64_decode($payload['iv']); // Here we will decrypt the value. If we are able to successfully decrypt it // we will then unserialize it and return it out to the caller. If ...
php
public function decrypt($payload, $unserialize = true) { $payload = $this->getJsonPayload($payload); $iv = base64_decode($payload['iv']); // Here we will decrypt the value. If we are able to successfully decrypt it // we will then unserialize it and return it out to the caller. If ...
[ "public", "function", "decrypt", "(", "$", "payload", ",", "$", "unserialize", "=", "true", ")", "{", "$", "payload", "=", "$", "this", "->", "getJsonPayload", "(", "$", "payload", ")", ";", "$", "iv", "=", "base64_decode", "(", "$", "payload", "[", ...
Decrypt the given value. @param mixed $payload @param bool $unserialize @return string @throws \Exception
[ "Decrypt", "the", "given", "value", "." ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Encrypter.php#L127-L145
matyhtf/framework
libs/Swoole/ModelLoader.php
ModelLoader.loadModel
public function loadModel($model_name, $db_key = 'master') { if (isset($this->_models[$db_key][$model_name])) { return $this->_models[$db_key][$model_name]; } else { $model_file = \Swoole::$app_path . '/models/' . str_replace('\\', '/', $model_name) . ...
php
public function loadModel($model_name, $db_key = 'master') { if (isset($this->_models[$db_key][$model_name])) { return $this->_models[$db_key][$model_name]; } else { $model_file = \Swoole::$app_path . '/models/' . str_replace('\\', '/', $model_name) . ...
[ "public", "function", "loadModel", "(", "$", "model_name", ",", "$", "db_key", "=", "'master'", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "_models", "[", "$", "db_key", "]", "[", "$", "model_name", "]", ")", ")", "{", "return", "$", "th...
加载Model @param $model_name @param $db_key @return mixed @throws Error
[ "加载Model" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/ModelLoader.php#L52-L77
matyhtf/framework
libs/Swoole/ModelLoader.php
ModelLoader.loadTable
public function loadTable($table_name, $db_key = 'master') { if (isset($this->_tables[$db_key][$table_name])) { return $this->_tables[$db_key][$table_name]; } else { $model = new Model($this->swoole, $db_key); $model->table = $table_name; ...
php
public function loadTable($table_name, $db_key = 'master') { if (isset($this->_tables[$db_key][$table_name])) { return $this->_tables[$db_key][$table_name]; } else { $model = new Model($this->swoole, $db_key); $model->table = $table_name; ...
[ "public", "function", "loadTable", "(", "$", "table_name", ",", "$", "db_key", "=", "'master'", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "_tables", "[", "$", "db_key", "]", "[", "$", "table_name", "]", ")", ")", "{", "return", "$", "th...
加载表 @param $table_name @param $db_key @return Model
[ "加载表" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/ModelLoader.php#L85-L98
matyhtf/framework
libs/Swoole/Protocol/CometServer.php
CometServer.onHttpRequest
function onHttpRequest(Swoole\Request $request) { //新连接 if (empty($request->post['session_id'])) { if (empty($request->post['type']) or $request->post['type'] != 'connect') { goto access_deny; } $this->log("Connect [fd={$request...
php
function onHttpRequest(Swoole\Request $request) { //新连接 if (empty($request->post['session_id'])) { if (empty($request->post['type']) or $request->post['type'] != 'connect') { goto access_deny; } $this->log("Connect [fd={$request...
[ "function", "onHttpRequest", "(", "Swoole", "\\", "Request", "$", "request", ")", "{", "//新连接", "if", "(", "empty", "(", "$", "request", "->", "post", "[", "'session_id'", "]", ")", ")", "{", "if", "(", "empty", "(", "$", "request", "->", "post", "["...
Http请求回调 @param Swoole\Request $request
[ "Http请求回调" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Protocol/CometServer.php#L52-L110
matyhtf/framework
libs/Swoole/Protocol/CometServer.php
CometServer.send
function send($session_id, $data, $opcode = self::OPCODE_TEXT_FRAME, $end = true) { //WebSocket if (!$this->isCometClient($session_id)) { return parent::send($session_id, $data, $opcode, $end); } //CometSession else { $session = $this->...
php
function send($session_id, $data, $opcode = self::OPCODE_TEXT_FRAME, $end = true) { //WebSocket if (!$this->isCometClient($session_id)) { return parent::send($session_id, $data, $opcode, $end); } //CometSession else { $session = $this->...
[ "function", "send", "(", "$", "session_id", ",", "$", "data", ",", "$", "opcode", "=", "self", "::", "OPCODE_TEXT_FRAME", ",", "$", "end", "=", "true", ")", "{", "//WebSocket", "if", "(", "!", "$", "this", "->", "isCometClient", "(", "$", "session_id",...
向浏览器发送数据 @param int $session_id @param string $data @return bool
[ "向浏览器发送数据" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Protocol/CometServer.php#L131-L158
matyhtf/framework
libs/Swoole/Protocol/CometServer.php
CometServer.sendMessage
function sendMessage(CometSession $session) { $request = $this->wait_requests[$session->id]; $response = new Swoole\Response; $response->setHeader('Access-Control-Allow-Origin', $this->origin); $response->body = json_encode(array('success' => 1, 'data' => $session->popMessage())); ...
php
function sendMessage(CometSession $session) { $request = $this->wait_requests[$session->id]; $response = new Swoole\Response; $response->setHeader('Access-Control-Allow-Origin', $this->origin); $response->body = json_encode(array('success' => 1, 'data' => $session->popMessage())); ...
[ "function", "sendMessage", "(", "CometSession", "$", "session", ")", "{", "$", "request", "=", "$", "this", "->", "wait_requests", "[", "$", "session", "->", "id", "]", ";", "$", "response", "=", "new", "Swoole", "\\", "Response", ";", "$", "response", ...
发送数据到sub通道 @param CometSession $session @return bool
[ "发送数据到sub通道" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Protocol/CometServer.php#L165-L173
matyhtf/framework
libs/Swoole/Protocol/CometServer.php
CometServer.onTimer
function onTimer($timerId) { $now = time(); //echo "timer $interval\n"; foreach ($this->wait_requests as $id => $request) { if ($request->time < $now - $this->request_timeout) { $response = new Swoole\Response; $response->setHea...
php
function onTimer($timerId) { $now = time(); //echo "timer $interval\n"; foreach ($this->wait_requests as $id => $request) { if ($request->time < $now - $this->request_timeout) { $response = new Swoole\Response; $response->setHea...
[ "function", "onTimer", "(", "$", "timerId", ")", "{", "$", "now", "=", "time", "(", ")", ";", "//echo \"timer $interval\\n\";", "foreach", "(", "$", "this", "->", "wait_requests", "as", "$", "id", "=>", "$", "request", ")", "{", "if", "(", "$", "reques...
定时器,检查某些连接是否已超过最大时间 @param $timerId
[ "定时器,检查某些连接是否已超过最大时间" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Protocol/CometServer.php#L179-L194
matyhtf/framework
libs/Swoole/Upload.php
Upload.save
function save($name, $filename = null, $allow = null) { //检查请求中是否存在上传的文件 if (empty($_FILES[$name]['type'])) { $this->error_msg = "No upload file '$name'!"; $this->error_code = 0; return false; } //文件存储的路径 $base_dir = empty($this->s...
php
function save($name, $filename = null, $allow = null) { //检查请求中是否存在上传的文件 if (empty($_FILES[$name]['type'])) { $this->error_msg = "No upload file '$name'!"; $this->error_code = 0; return false; } //文件存储的路径 $base_dir = empty($this->s...
[ "function", "save", "(", "$", "name", ",", "$", "filename", "=", "null", ",", "$", "allow", "=", "null", ")", "{", "//检查请求中是否存在上传的文件", "if", "(", "empty", "(", "$", "_FILES", "[", "$", "name", "]", "[", "'type'", "]", ")", ")", "{", "$", "this", ...
保存上传的图片 @param $name @param null $filename @param null $allow @return bool
[ "保存上传的图片" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Upload.php#L119-L267
matyhtf/framework
libs/Swoole/Upload.php
Upload.getMimeType
public function getMimeType($mime) { if (isset($this->mimes[$mime])) { return $this->mimes[$mime]; } else { return false; } }
php
public function getMimeType($mime) { if (isset($this->mimes[$mime])) { return $this->mimes[$mime]; } else { return false; } }
[ "public", "function", "getMimeType", "(", "$", "mime", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "mimes", "[", "$", "mime", "]", ")", ")", "{", "return", "$", "this", "->", "mimes", "[", "$", "mime", "]", ";", "}", "else", "{", "ret...
获取MIME对应的扩展名 @param $mime @return bool
[ "获取MIME对应的扩展名" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Upload.php#L273-L283
matyhtf/framework
libs/Swoole/Upload.php
Upload.getFileExt
static public function getFileExt($file) { $s = strrchr($file, '.'); if ($s === false) { return false; } return strtolower(trim(substr($s, 1))); }
php
static public function getFileExt($file) { $s = strrchr($file, '.'); if ($s === false) { return false; } return strtolower(trim(substr($s, 1))); }
[ "static", "public", "function", "getFileExt", "(", "$", "file", ")", "{", "$", "s", "=", "strrchr", "(", "$", "file", ",", "'.'", ")", ";", "if", "(", "$", "s", "===", "false", ")", "{", "return", "false", ";", "}", "return", "strtolower", "(", "...
根据文件名获取扩展名 @param $file @return string
[ "根据文件名获取扩展名" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Upload.php#L290-L298
matyhtf/framework
libs/Swoole/Content.php
Content.paging
function paging(&$content, $spsize, $sptag) { if(strlen($content)<$spsize) return false; $bds = explode('<',$content); $npageBody = ""; $istable = 0; $content = ""; foreach($bds as $i=>$k) { if($i==0){$npageBody .= $bds[$i]; continue;} $bds[$i] = "<".$bds[$i]; if(strlen($bds[$i])>6) { $tn...
php
function paging(&$content, $spsize, $sptag) { if(strlen($content)<$spsize) return false; $bds = explode('<',$content); $npageBody = ""; $istable = 0; $content = ""; foreach($bds as $i=>$k) { if($i==0){$npageBody .= $bds[$i]; continue;} $bds[$i] = "<".$bds[$i]; if(strlen($bds[$i])>6) { $tn...
[ "function", "paging", "(", "&", "$", "content", ",", "$", "spsize", ",", "$", "sptag", ")", "{", "if", "(", "strlen", "(", "$", "content", ")", "<", "$", "spsize", ")", "return", "false", ";", "$", "bds", "=", "explode", "(", "'<'", ",", "$", "...
自动产生分页代码 根据$size提供的长度 将$content分成$sptag分割开的一个文本,可以使用explode实现内容划分 @param $content 内容 @param $spsize 每页内容长度 @param $sptag 分隔符 @return bool 是否成功
[ "自动产生分页代码", "根据$size提供的长度", "将$content分成$sptag分割开的一个文本,可以使用explode实现内容划分" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Content.php#L23-L54
matyhtf/framework
libs/Swoole/Content.php
Content.image_local
function image_local(&$content, $dir='') { if(empty($dir)) $dir = UPLOAD_DIR.'/extend/'.date('Ym')."/".date("d"); if(!file_exists($dir)) { mkdir(WEBPATH.$dir,0777,true); } $chunklist = array (); $chunklist = explode("\n",$content); $links = array (); $regs = array (); $source = array(); $i = ...
php
function image_local(&$content, $dir='') { if(empty($dir)) $dir = UPLOAD_DIR.'/extend/'.date('Ym')."/".date("d"); if(!file_exists($dir)) { mkdir(WEBPATH.$dir,0777,true); } $chunklist = array (); $chunklist = explode("\n",$content); $links = array (); $regs = array (); $source = array(); $i = ...
[ "function", "image_local", "(", "&", "$", "content", ",", "$", "dir", "=", "''", ")", "{", "if", "(", "empty", "(", "$", "dir", ")", ")", "$", "dir", "=", "UPLOAD_DIR", ".", "'/extend/'", ".", "date", "(", "'Ym'", ")", ".", "\"/\"", ".", "date", ...
自动将给定的内容$data中远程图片的url改为本地图片,并自动将远程图片保存到本地 @param $data @return unknown_type
[ "自动将给定的内容$data中远程图片的url改为本地图片,并自动将远程图片保存到本地" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Content.php#L61-L99
matyhtf/framework
libs/Swoole/Content.php
Content._pinyin
private function _pinyin($num, &$pinyin) { if($num>0&&$num<160) { return chr($num); } elseif($num<-20319||$num>-10247) { return ""; } else { for($i=count($pinyin)-1;$i>=0;$i--){if($pinyin[$i][1]<=$num)break;} return $pinyin[$i][0]; } }
php
private function _pinyin($num, &$pinyin) { if($num>0&&$num<160) { return chr($num); } elseif($num<-20319||$num>-10247) { return ""; } else { for($i=count($pinyin)-1;$i>=0;$i--){if($pinyin[$i][1]<=$num)break;} return $pinyin[$i][0]; } }
[ "private", "function", "_pinyin", "(", "$", "num", ",", "&", "$", "pinyin", ")", "{", "if", "(", "$", "num", ">", "0", "&&", "$", "num", "<", "160", ")", "{", "return", "chr", "(", "$", "num", ")", ";", "}", "elseif", "(", "$", "num", "<", ...
主要是用于pinyin方法
[ "主要是用于pinyin方法" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Content.php#L112-L127
matyhtf/framework
libs/Swoole/Content.php
Content.num2han
function num2han($num) { $array = array('〇','一','二','三','四','五','六','七','八','九'); $num = (string) $num; $len = strlen($num); $str = ''; for($i=0;$i<$len;$i++) { $str.=$array[$num{$i}]; } return $str; }
php
function num2han($num) { $array = array('〇','一','二','三','四','五','六','七','八','九'); $num = (string) $num; $len = strlen($num); $str = ''; for($i=0;$i<$len;$i++) { $str.=$array[$num{$i}]; } return $str; }
[ "function", "num2han", "(", "$", "num", ")", "{", "$", "array", "=", "array", "(", "'〇','", "一", "','二'", ",", "'三','", "四", "','五'", ",", "'六','", "七", "','八'", ",", "'九');", "", "", "", "", "", "", "", "", "$", "num", "=", "(", "string", ...
数字转汉字表示
[ "数字转汉字表示" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Content.php#L132-L143
matyhtf/framework
libs/Swoole/Memory/Struct.php
Struct.pack
function pack(array $data) { if (count($data) != count($this->fileds)) { throw new InvalidParam("{$this->class}: invalid data."); } $_binStr = ''; foreach ($this->fileds as $k => $field) { if (!isset($data[$k])) { t...
php
function pack(array $data) { if (count($data) != count($this->fileds)) { throw new InvalidParam("{$this->class}: invalid data."); } $_binStr = ''; foreach ($this->fileds as $k => $field) { if (!isset($data[$k])) { t...
[ "function", "pack", "(", "array", "$", "data", ")", "{", "if", "(", "count", "(", "$", "data", ")", "!=", "count", "(", "$", "this", "->", "fileds", ")", ")", "{", "throw", "new", "InvalidParam", "(", "\"{$this->class}: invalid data.\"", ")", ";", "}",...
打包数据 @param array $data @return string @throws InvalidParam
[ "打包数据" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Memory/Struct.php#L163-L256
matyhtf/framework
libs/Swoole/Memory/Struct.php
Struct.unpack
function unpack($str) { $data = array(); foreach ($this->fileds as $k => $field) { /** * @var $field Field */ switch ($field->type) { case Field::INT: switch ($field->size) {...
php
function unpack($str) { $data = array(); foreach ($this->fileds as $k => $field) { /** * @var $field Field */ switch ($field->type) { case Field::INT: switch ($field->size) {...
[ "function", "unpack", "(", "$", "str", ")", "{", "$", "data", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "fileds", "as", "$", "k", "=>", "$", "field", ")", "{", "/**\n * @var $field Field\n */", "switch", "(", ...
解包数据 @param $str @return array
[ "解包数据" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Memory/Struct.php#L263-L331
matyhtf/framework
libs/Swoole/Request.php
Request.setGlobal
function setGlobal() { /** * 将HTTP头信息赋值给$_SERVER超全局变量 */ foreach ($this->header as $key => $value) { $_key = 'HTTP_' . strtoupper(str_replace('-', '_', $key)); $this->server[$_key] = $value; } $_GET = $this->get; $_POST = $th...
php
function setGlobal() { /** * 将HTTP头信息赋值给$_SERVER超全局变量 */ foreach ($this->header as $key => $value) { $_key = 'HTTP_' . strtoupper(str_replace('-', '_', $key)); $this->server[$_key] = $value; } $_GET = $this->get; $_POST = $th...
[ "function", "setGlobal", "(", ")", "{", "/**\n * 将HTTP头信息赋值给$_SERVER超全局变量\n */", "foreach", "(", "$", "this", "->", "header", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "_key", "=", "'HTTP_'", ".", "strtoupper", "(", "str_replace", "(...
将原始请求信息转换到PHP超全局变量中
[ "将原始请求信息转换到PHP超全局变量中" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Request.php#L55-L73
matyhtf/framework
libs/Swoole/Request.php
Request.initWithLamp
function initWithLamp() { $this->get = $_GET; $this->post = $_POST; $this->cookie = $_COOKIE; $this->server = $_SERVER; $this->request = $_REQUEST; }
php
function initWithLamp() { $this->get = $_GET; $this->post = $_POST; $this->cookie = $_COOKIE; $this->server = $_SERVER; $this->request = $_REQUEST; }
[ "function", "initWithLamp", "(", ")", "{", "$", "this", "->", "get", "=", "$", "_GET", ";", "$", "this", "->", "post", "=", "$", "_POST", ";", "$", "this", "->", "cookie", "=", "$", "_COOKIE", ";", "$", "this", "->", "server", "=", "$", "_SERVER"...
LAMP环境初始化
[ "LAMP环境初始化" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Request.php#L78-L85
matyhtf/framework
libs/Swoole/Request.php
Request.download
function download($mime, $filename) { \Swoole::$php->http->header('Content-type', $mime); \Swoole::$php->http->header('Content-Disposition', "attachment; filename=$filename"); }
php
function download($mime, $filename) { \Swoole::$php->http->header('Content-type', $mime); \Swoole::$php->http->header('Content-Disposition', "attachment; filename=$filename"); }
[ "function", "download", "(", "$", "mime", ",", "$", "filename", ")", "{", "\\", "Swoole", "::", "$", "php", "->", "http", "->", "header", "(", "'Content-type'", ",", "$", "mime", ")", ";", "\\", "Swoole", "::", "$", "php", "->", "http", "->", "head...
发送下载声明
[ "发送下载声明" ]
train
https://github.com/matyhtf/framework/blob/785b5cf463dd01ad07410b2a37d465c629e9798b/libs/Swoole/Request.php#L109-L113