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
spatie/laravel-tags
src/HasTags.php
HasTags.scopeWithAnyTags
public function scopeWithAnyTags(Builder $query, $tags, string $type = null): Builder { $tags = static::convertToTags($tags, $type); return $query->whereHas('tags', function (Builder $query) use ($tags) { $tagIds = collect($tags)->pluck('id'); $query->whereIn('tags.id', $ta...
php
public function scopeWithAnyTags(Builder $query, $tags, string $type = null): Builder { $tags = static::convertToTags($tags, $type); return $query->whereHas('tags', function (Builder $query) use ($tags) { $tagIds = collect($tags)->pluck('id'); $query->whereIn('tags.id', $ta...
[ "public", "function", "scopeWithAnyTags", "(", "Builder", "$", "query", ",", "$", "tags", ",", "string", "$", "type", "=", "null", ")", ":", "Builder", "{", "$", "tags", "=", "static", "::", "convertToTags", "(", "$", "tags", ",", "$", "type", ")", "...
@param \Illuminate\Database\Eloquent\Builder $query @param array|\ArrayAccess|\Spatie\Tags\Tag $tags @return \Illuminate\Database\Eloquent\Builder
[ "@param", "\\", "Illuminate", "\\", "Database", "\\", "Eloquent", "\\", "Builder", "$query", "@param", "array|", "\\", "ArrayAccess|", "\\", "Spatie", "\\", "Tags", "\\", "Tag", "$tags" ]
train
https://github.com/spatie/laravel-tags/blob/b452ce85a285173028917cbc29dae2d63b184033/src/HasTags.php#L100-L109
spatie/laravel-tags
src/HasTags.php
HasTags.detachTags
public function detachTags($tags) { $tags = static::convertToTags($tags); collect($tags) ->filter() ->each(function (Tag $tag) { $this->tags()->detach($tag); }); return $this; }
php
public function detachTags($tags) { $tags = static::convertToTags($tags); collect($tags) ->filter() ->each(function (Tag $tag) { $this->tags()->detach($tag); }); return $this; }
[ "public", "function", "detachTags", "(", "$", "tags", ")", "{", "$", "tags", "=", "static", "::", "convertToTags", "(", "$", "tags", ")", ";", "collect", "(", "$", "tags", ")", "->", "filter", "(", ")", "->", "each", "(", "function", "(", "Tag", "$...
@param array|\ArrayAccess $tags @return $this
[ "@param", "array|", "\\", "ArrayAccess", "$tags" ]
train
https://github.com/spatie/laravel-tags/blob/b452ce85a285173028917cbc29dae2d63b184033/src/HasTags.php#L175-L186
spatie/laravel-tags
src/HasTags.php
HasTags.syncTagsWithType
public function syncTagsWithType($tags, string $type = null) { $className = static::getTagClassName(); $tags = collect($className::findOrCreate($tags, $type)); $this->syncTagIds($tags->pluck('id')->toArray(), $type); return $this; }
php
public function syncTagsWithType($tags, string $type = null) { $className = static::getTagClassName(); $tags = collect($className::findOrCreate($tags, $type)); $this->syncTagIds($tags->pluck('id')->toArray(), $type); return $this; }
[ "public", "function", "syncTagsWithType", "(", "$", "tags", ",", "string", "$", "type", "=", "null", ")", "{", "$", "className", "=", "static", "::", "getTagClassName", "(", ")", ";", "$", "tags", "=", "collect", "(", "$", "className", "::", "findOrCreat...
@param array|\ArrayAccess $tags @param string|null $type @return $this
[ "@param", "array|", "\\", "ArrayAccess", "$tags", "@param", "string|null", "$type" ]
train
https://github.com/spatie/laravel-tags/blob/b452ce85a285173028917cbc29dae2d63b184033/src/HasTags.php#L220-L229
spatie/laravel-tags
src/HasTags.php
HasTags.syncTagIds
protected function syncTagIds($ids, string $type = null, $detaching = true) { $isUpdated = false; // Get a list of tag_ids for all current tags $current = $this->tags() ->newPivotStatement() ->where('taggable_id', $this->getKey()) ->where('taggable_type',...
php
protected function syncTagIds($ids, string $type = null, $detaching = true) { $isUpdated = false; // Get a list of tag_ids for all current tags $current = $this->tags() ->newPivotStatement() ->where('taggable_id', $this->getKey()) ->where('taggable_type',...
[ "protected", "function", "syncTagIds", "(", "$", "ids", ",", "string", "$", "type", "=", "null", ",", "$", "detaching", "=", "true", ")", "{", "$", "isUpdated", "=", "false", ";", "// Get a list of tag_ids for all current tags", "$", "current", "=", "$", "th...
Use in place of eloquent's sync() method so that the tag type may be optionally specified. @param $ids @param string|null $type @param bool $detaching
[ "Use", "in", "place", "of", "eloquent", "s", "sync", "()", "method", "so", "that", "the", "tag", "type", "may", "be", "optionally", "specified", "." ]
train
https://github.com/spatie/laravel-tags/blob/b452ce85a285173028917cbc29dae2d63b184033/src/HasTags.php#L268-L313
walkor/GatewayWorker
src/Lib/DbConnection.php
DbConnection.select
public function select($cols = '*') { $this->type = 'SELECT'; if (!is_array($cols)) { $cols = array($cols); } $this->cols($cols); return $this; }
php
public function select($cols = '*') { $this->type = 'SELECT'; if (!is_array($cols)) { $cols = array($cols); } $this->cols($cols); return $this; }
[ "public", "function", "select", "(", "$", "cols", "=", "'*'", ")", "{", "$", "this", "->", "type", "=", "'SELECT'", ";", "if", "(", "!", "is_array", "(", "$", "cols", ")", ")", "{", "$", "cols", "=", "array", "(", "$", "cols", ")", ";", "}", ...
选择哪些列 @param string|array $cols @return self
[ "选择哪些列" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/Lib/DbConnection.php#L215-L223
walkor/GatewayWorker
src/Lib/DbConnection.php
DbConnection.delete
public function delete($table) { $this->type = 'DELETE'; $this->table = $this->quoteName($table); $this->fromRaw($this->quoteName($table)); return $this; }
php
public function delete($table) { $this->type = 'DELETE'; $this->table = $this->quoteName($table); $this->fromRaw($this->quoteName($table)); return $this; }
[ "public", "function", "delete", "(", "$", "table", ")", "{", "$", "this", "->", "type", "=", "'DELETE'", ";", "$", "this", "->", "table", "=", "$", "this", "->", "quoteName", "(", "$", "table", ")", ";", "$", "this", "->", "fromRaw", "(", "$", "t...
从哪个表删除 @param string $table @return self
[ "从哪个表删除" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/Lib/DbConnection.php#L231-L237
walkor/GatewayWorker
src/Lib/DbConnection.php
DbConnection.update
public function update($table) { $this->type = 'UPDATE'; $this->table = $this->quoteName($table); return $this; }
php
public function update($table) { $this->type = 'UPDATE'; $this->table = $this->quoteName($table); return $this; }
[ "public", "function", "update", "(", "$", "table", ")", "{", "$", "this", "->", "type", "=", "'UPDATE'", ";", "$", "this", "->", "table", "=", "$", "this", "->", "quoteName", "(", "$", "table", ")", ";", "return", "$", "this", ";", "}" ]
更新哪个表 @param string $table @return self
[ "更新哪个表" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/Lib/DbConnection.php#L245-L250
walkor/GatewayWorker
src/Lib/DbConnection.php
DbConnection.insert
public function insert($table) { $this->type = 'INSERT'; $this->table = $this->quoteName($table); return $this; }
php
public function insert($table) { $this->type = 'INSERT'; $this->table = $this->quoteName($table); return $this; }
[ "public", "function", "insert", "(", "$", "table", ")", "{", "$", "this", "->", "type", "=", "'INSERT'", ";", "$", "this", "->", "table", "=", "$", "this", "->", "quoteName", "(", "$", "table", ")", ";", "return", "$", "this", ";", "}" ]
向哪个表插入 @param string $table @return self
[ "向哪个表插入" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/Lib/DbConnection.php#L258-L263
walkor/GatewayWorker
src/Lib/DbConnection.php
DbConnection.getBindValuesSELECT
public function getBindValuesSELECT() { $bind_values = $this->bind_values; $i = 1; foreach ($this->bind_where as $val) { $bind_values[$i] = $val; $i++; } foreach ($this->bind_having as $val) { $bind_values[$i] = $val; ...
php
public function getBindValuesSELECT() { $bind_values = $this->bind_values; $i = 1; foreach ($this->bind_where as $val) { $bind_values[$i] = $val; $i++; } foreach ($this->bind_having as $val) { $bind_values[$i] = $val; ...
[ "public", "function", "getBindValuesSELECT", "(", ")", "{", "$", "bind_values", "=", "$", "this", "->", "bind_values", ";", "$", "i", "=", "1", ";", "foreach", "(", "$", "this", "->", "bind_where", "as", "$", "val", ")", "{", "$", "bind_values", "[", ...
获取绑定在占位符上的值 @return array
[ "获取绑定在占位符上的值" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/Lib/DbConnection.php#L492-L505
walkor/GatewayWorker
src/Lib/DbConnection.php
DbConnection.join
public function join($table, $cond = null, $type = '') { return $this->joinInternal($type, $table, $cond); }
php
public function join($table, $cond = null, $type = '') { return $this->joinInternal($type, $table, $cond); }
[ "public", "function", "join", "(", "$", "table", ",", "$", "cond", "=", "null", ",", "$", "type", "=", "''", ")", "{", "return", "$", "this", "->", "joinInternal", "(", "$", "type", ",", "$", "table", ",", "$", "cond", ")", ";", "}" ]
增加 join 语句 @param string $table @param string $cond @param string $type @return self @throws Exception
[ "增加", "join", "语句" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/Lib/DbConnection.php#L591-L594
walkor/GatewayWorker
src/Lib/DbConnection.php
DbConnection.joinInternal
protected function joinInternal($join, $table, $cond = null) { if (!$this->from) { throw new Exception('Cannot join() without from()'); } $join = strtoupper(ltrim("$join JOIN")); $table = $this->quoteName($table); ...
php
protected function joinInternal($join, $table, $cond = null) { if (!$this->from) { throw new Exception('Cannot join() without from()'); } $join = strtoupper(ltrim("$join JOIN")); $table = $this->quoteName($table); ...
[ "protected", "function", "joinInternal", "(", "$", "join", ",", "$", "table", ",", "$", "cond", "=", "null", ")", "{", "if", "(", "!", "$", "this", "->", "from", ")", "{", "throw", "new", "Exception", "(", "'Cannot join() without from()'", ")", ";", "}...
增加 join 语句 @param string $join inner, left, natural @param string $table @param string $cond @return self @throws Exception
[ "增加", "join", "语句" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/Lib/DbConnection.php#L605-L616
walkor/GatewayWorker
src/Lib/DbConnection.php
DbConnection.fixJoinCondition
protected function fixJoinCondition($cond) { if (!$cond) { return ''; } $cond = $this->quoteNamesIn($cond); if (strtoupper(substr(ltrim($cond), 0, 3)) == 'ON ') { return $cond; } if (strtoupper(substr(ltrim($cond), 0, 6)) == 'USING ') { ...
php
protected function fixJoinCondition($cond) { if (!$cond) { return ''; } $cond = $this->quoteNamesIn($cond); if (strtoupper(substr(ltrim($cond), 0, 3)) == 'ON ') { return $cond; } if (strtoupper(substr(ltrim($cond), 0, 6)) == 'USING ') { ...
[ "protected", "function", "fixJoinCondition", "(", "$", "cond", ")", "{", "if", "(", "!", "$", "cond", ")", "{", "return", "''", ";", "}", "$", "cond", "=", "$", "this", "->", "quoteNamesIn", "(", "$", "cond", ")", ";", "if", "(", "strtoupper", "(",...
quote @param string $cond @return string
[ "quote" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/Lib/DbConnection.php#L625-L642
walkor/GatewayWorker
src/Lib/DbConnection.php
DbConnection.joinSubSelect
public function joinSubSelect($join, $spec, $name, $cond = null) { if (!$this->from) { throw new \Exception('Cannot join() without from() first.'); } $join = strtoupper(ltrim("$join JOIN")); $name = $this->quoteName($name...
php
public function joinSubSelect($join, $spec, $name, $cond = null) { if (!$this->from) { throw new \Exception('Cannot join() without from() first.'); } $join = strtoupper(ltrim("$join JOIN")); $name = $this->quoteName($name...
[ "public", "function", "joinSubSelect", "(", "$", "join", ",", "$", "spec", ",", "$", "name", ",", "$", "cond", "=", "null", ")", "{", "if", "(", "!", "$", "this", "->", "from", ")", "{", "throw", "new", "\\", "Exception", "(", "'Cannot join() without...
joinSubSelect @param string $join inner, left, natural @param string $spec @param string $name sub-select 的别名 @param string $cond @return self @throws Exception
[ "joinSubSelect" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/Lib/DbConnection.php#L693-L704
walkor/GatewayWorker
src/Lib/DbConnection.php
DbConnection.groupBy
public function groupBy(array $cols) { foreach ($cols as $col) { $this->group_by[] = $this->quoteNamesIn($col); } return $this; }
php
public function groupBy(array $cols) { foreach ($cols as $col) { $this->group_by[] = $this->quoteNamesIn($col); } return $this; }
[ "public", "function", "groupBy", "(", "array", "$", "cols", ")", "{", "foreach", "(", "$", "cols", "as", "$", "col", ")", "{", "$", "this", "->", "group_by", "[", "]", "=", "$", "this", "->", "quoteNamesIn", "(", "$", "col", ")", ";", "}", "retur...
group by 语句 @param array $cols @return self
[ "group", "by", "语句" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/Lib/DbConnection.php#L712-L718
walkor/GatewayWorker
src/Lib/DbConnection.php
DbConnection.page
public function page($page) { $this->limit = 0; $this->offset = 0; $page = (int)$page; if ($page > 0) { $this->limit = $this->paging; $this->offset = $this->paging * ($page - 1); } return $this; }
php
public function page($page) { $this->limit = 0; $this->offset = 0; $page = (int)$page; if ($page > 0) { $this->limit = $this->paging; $this->offset = $this->paging * ($page - 1); } return $this; }
[ "public", "function", "page", "(", "$", "page", ")", "{", "$", "this", "->", "limit", "=", "0", ";", "$", "this", "->", "offset", "=", "0", ";", "$", "page", "=", "(", "int", ")", "$", "page", ";", "if", "(", "$", "page", ">", "0", ")", "{"...
设置每页的记录数量 @param int $page @return self
[ "设置每页的记录数量" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/Lib/DbConnection.php#L750-L761
walkor/GatewayWorker
src/Lib/DbConnection.php
DbConnection.reset
protected function reset() { $this->resetFlags(); $this->cols = array(); $this->from = array(); $this->from_key = -1; $this->where = array(); $this->group_by = array(); $this->having = array(); $this->order_by = array(); ...
php
protected function reset() { $this->resetFlags(); $this->cols = array(); $this->from = array(); $this->from_key = -1; $this->where = array(); $this->group_by = array(); $this->having = array(); $this->order_by = array(); ...
[ "protected", "function", "reset", "(", ")", "{", "$", "this", "->", "resetFlags", "(", ")", ";", "$", "this", "->", "cols", "=", "array", "(", ")", ";", "$", "this", "->", "from", "=", "array", "(", ")", ";", "$", "this", "->", "from_key", "=", ...
重置
[ "重置" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/Lib/DbConnection.php#L790-L803
walkor/GatewayWorker
src/Lib/DbConnection.php
DbConnection.resetAll
protected function resetAll() { $this->union = array(); $this->for_update = false; $this->cols = array(); $this->from = array(); $this->from_key = -1; $this->group_by = array(); $...
php
protected function resetAll() { $this->union = array(); $this->for_update = false; $this->cols = array(); $this->from = array(); $this->from_key = -1; $this->group_by = array(); $...
[ "protected", "function", "resetAll", "(", ")", "{", "$", "this", "->", "union", "=", "array", "(", ")", ";", "$", "this", "->", "for_update", "=", "false", ";", "$", "this", "->", "cols", "=", "array", "(", ")", ";", "$", "this", "->", "from", "=...
清除所有数据
[ "清除所有数据" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/Lib/DbConnection.php#L808-L831
walkor/GatewayWorker
src/Lib/DbConnection.php
DbConnection.buildSELECT
protected function buildSELECT() { return 'SELECT' . $this->buildFlags() . $this->buildCols() . $this->buildFrom() . $this->buildWhere() . $this->buildGroupBy() . $this->buildHaving() . $this->buildOrderBy() . $this->buildLimit() . $thi...
php
protected function buildSELECT() { return 'SELECT' . $this->buildFlags() . $this->buildCols() . $this->buildFrom() . $this->buildWhere() . $this->buildGroupBy() . $this->buildHaving() . $this->buildOrderBy() . $this->buildLimit() . $thi...
[ "protected", "function", "buildSELECT", "(", ")", "{", "return", "'SELECT'", ".", "$", "this", "->", "buildFlags", "(", ")", ".", "$", "this", "->", "buildCols", "(", ")", ".", "$", "this", "->", "buildFrom", "(", ")", ".", "$", "this", "->", "buildW...
创建 SELECT SQL @return string
[ "创建", "SELECT", "SQL" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/Lib/DbConnection.php#L838-L850
walkor/GatewayWorker
src/Lib/DbConnection.php
DbConnection.buildDELETE
protected function buildDELETE() { return 'DELETE' . $this->buildFlags() . $this->buildFrom() . $this->buildWhere() . $this->buildOrderBy() . $this->buildLimit() . $this->buildReturning(); }
php
protected function buildDELETE() { return 'DELETE' . $this->buildFlags() . $this->buildFrom() . $this->buildWhere() . $this->buildOrderBy() . $this->buildLimit() . $this->buildReturning(); }
[ "protected", "function", "buildDELETE", "(", ")", "{", "return", "'DELETE'", ".", "$", "this", "->", "buildFlags", "(", ")", ".", "$", "this", "->", "buildFrom", "(", ")", ".", "$", "this", "->", "buildWhere", "(", ")", ".", "$", "this", "->", "build...
创建 DELETE SQL
[ "创建", "DELETE", "SQL" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/Lib/DbConnection.php#L855-L864
walkor/GatewayWorker
src/Lib/DbConnection.php
DbConnection.buildCols
protected function buildCols() { if (!$this->cols) { throw new Exception('No columns in the SELECT.'); } $cols = array(); foreach ($this->cols as $key => $val) { if (is_int($key)) { $cols[] = $this->quoteNamesIn($val); } else { ...
php
protected function buildCols() { if (!$this->cols) { throw new Exception('No columns in the SELECT.'); } $cols = array(); foreach ($this->cols as $key => $val) { if (is_int($key)) { $cols[] = $this->quoteNamesIn($val); } else { ...
[ "protected", "function", "buildCols", "(", ")", "{", "if", "(", "!", "$", "this", "->", "cols", ")", "{", "throw", "new", "Exception", "(", "'No columns in the SELECT.'", ")", ";", "}", "$", "cols", "=", "array", "(", ")", ";", "foreach", "(", "$", "...
生成 SELECT 列语句 @return string @throws Exception
[ "生成", "SELECT", "列语句" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/Lib/DbConnection.php#L872-L888
walkor/GatewayWorker
src/Lib/DbConnection.php
DbConnection.buildFrom
protected function buildFrom() { if (!$this->from) { return ''; } $refs = array(); foreach ($this->from as $from) { $refs[] = implode(' ', $from); } return ' FROM' . $this->indentCsv($refs); }
php
protected function buildFrom() { if (!$this->from) { return ''; } $refs = array(); foreach ($this->from as $from) { $refs[] = implode(' ', $from); } return ' FROM' . $this->indentCsv($refs); }
[ "protected", "function", "buildFrom", "(", ")", "{", "if", "(", "!", "$", "this", "->", "from", ")", "{", "return", "''", ";", "}", "$", "refs", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "from", "as", "$", "from", ")", "{"...
生成 FROM 语句. @return string
[ "生成", "FROM", "语句", "." ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/Lib/DbConnection.php#L895-L906
walkor/GatewayWorker
src/Lib/DbConnection.php
DbConnection.orWhere
public function orWhere($cond) { if (is_array($cond)) { foreach ($cond as $key => $val) { if (is_string($key)) { $this->addWhere('OR', array($key, $val)); } else { $this->addWhere('OR', array($val)); } ...
php
public function orWhere($cond) { if (is_array($cond)) { foreach ($cond as $key => $val) { if (is_string($key)) { $this->addWhere('OR', array($key, $val)); } else { $this->addWhere('OR', array($val)); } ...
[ "public", "function", "orWhere", "(", "$", "cond", ")", "{", "if", "(", "is_array", "(", "$", "cond", ")", ")", "{", "foreach", "(", "$", "cond", "as", "$", "key", "=>", "$", "val", ")", "{", "if", "(", "is_string", "(", "$", "key", ")", ")", ...
or where @param string|array $cond @return self
[ "or", "where" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/Lib/DbConnection.php#L975-L989
walkor/GatewayWorker
src/Lib/DbConnection.php
DbConnection.orderByASC
public function orderByASC(array $cols, $order_asc = true) { $this->order_asc = $order_asc; return $this->addOrderBy($cols); }
php
public function orderByASC(array $cols, $order_asc = true) { $this->order_asc = $order_asc; return $this->addOrderBy($cols); }
[ "public", "function", "orderByASC", "(", "array", "$", "cols", ",", "$", "order_asc", "=", "true", ")", "{", "$", "this", "->", "order_asc", "=", "$", "order_asc", ";", "return", "$", "this", "->", "addOrderBy", "(", "$", "cols", ")", ";", "}" ]
order by ASC OR DESC @param array $cols @param bool $order_asc @return self
[ "order", "by", "ASC", "OR", "DESC" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/Lib/DbConnection.php#L1033-L1037
walkor/GatewayWorker
src/Lib/DbConnection.php
DbConnection.bindValues
public function bindValues(array $bind_values) { foreach ($bind_values as $key => $val) { $this->bindValue($key, $val); } return $this; }
php
public function bindValues(array $bind_values) { foreach ($bind_values as $key => $val) { $this->bindValue($key, $val); } return $this; }
[ "public", "function", "bindValues", "(", "array", "$", "bind_values", ")", "{", "foreach", "(", "$", "bind_values", "as", "$", "key", "=>", "$", "val", ")", "{", "$", "this", "->", "bindValue", "(", "$", "key", ",", "$", "val", ")", ";", "}", "retu...
批量为占位符绑定值 @param array $bind_values @return self
[ "批量为占位符绑定值" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/Lib/DbConnection.php#L1081-L1087
walkor/GatewayWorker
src/Lib/DbConnection.php
DbConnection.setFlag
protected function setFlag($flag, $enable = true) { if ($enable) { $this->flags[$flag] = true; } else { unset($this->flags[$flag]); } }
php
protected function setFlag($flag, $enable = true) { if ($enable) { $this->flags[$flag] = true; } else { unset($this->flags[$flag]); } }
[ "protected", "function", "setFlag", "(", "$", "flag", ",", "$", "enable", "=", "true", ")", "{", "if", "(", "$", "enable", ")", "{", "$", "this", "->", "flags", "[", "$", "flag", "]", "=", "true", ";", "}", "else", "{", "unset", "(", "$", "this...
设置 flag. @param string $flag @param bool $enable
[ "设置", "flag", "." ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/Lib/DbConnection.php#L1121-L1128
walkor/GatewayWorker
src/Lib/DbConnection.php
DbConnection.addClauseCondWithBind
protected function addClauseCondWithBind($clause, $andor, $conditions) { $cond = array_shift($conditions); $cond = $this->quoteNamesIn($cond); $bind =& $this->{"bind_{$clause}"}; foreach ($conditions as $value) { $bind[] = $value; } $clause =& $this->$cl...
php
protected function addClauseCondWithBind($clause, $andor, $conditions) { $cond = array_shift($conditions); $cond = $this->quoteNamesIn($cond); $bind =& $this->{"bind_{$clause}"}; foreach ($conditions as $value) { $bind[] = $value; } $clause =& $this->$cl...
[ "protected", "function", "addClauseCondWithBind", "(", "$", "clause", ",", "$", "andor", ",", "$", "conditions", ")", "{", "$", "cond", "=", "array_shift", "(", "$", "conditions", ")", ";", "$", "cond", "=", "$", "this", "->", "quoteNamesIn", "(", "$", ...
添加条件和绑定值 @param string $clause where 、having等 @param string $andor AND、OR等 @param array $conditions
[ "添加条件和绑定值" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/Lib/DbConnection.php#L1160-L1176
walkor/GatewayWorker
src/Lib/DbConnection.php
DbConnection.addOrderBy
protected function addOrderBy(array $spec) { foreach ($spec as $col) { $this->order_by[] = $this->quoteNamesIn($col); } return $this; }
php
protected function addOrderBy(array $spec) { foreach ($spec as $col) { $this->order_by[] = $this->quoteNamesIn($col); } return $this; }
[ "protected", "function", "addOrderBy", "(", "array", "$", "spec", ")", "{", "foreach", "(", "$", "spec", "as", "$", "col", ")", "{", "$", "this", "->", "order_by", "[", "]", "=", "$", "this", "->", "quoteNamesIn", "(", "$", "col", ")", ";", "}", ...
增加 order by @param array $spec The columns and direction to order by. @return self
[ "增加", "order", "by" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/Lib/DbConnection.php#L1197-L1203
walkor/GatewayWorker
src/Lib/DbConnection.php
DbConnection.buildOrderBy
protected function buildOrderBy() { if (!$this->order_by) { return ''; } if ($this->order_asc) { return ' ORDER BY' . $this->indentCsv($this->order_by) . ' ASC'; } else { return ' ORDER BY' . $this->indentCsv($this->order_by) . ' DESC'; } ...
php
protected function buildOrderBy() { if (!$this->order_by) { return ''; } if ($this->order_asc) { return ' ORDER BY' . $this->indentCsv($this->order_by) . ' ASC'; } else { return ' ORDER BY' . $this->indentCsv($this->order_by) . ' DESC'; } ...
[ "protected", "function", "buildOrderBy", "(", ")", "{", "if", "(", "!", "$", "this", "->", "order_by", ")", "{", "return", "''", ";", "}", "if", "(", "$", "this", "->", "order_asc", ")", "{", "return", "' ORDER BY'", ".", "$", "this", "->", "indentCs...
生成 order by 语句 @return string
[ "生成", "order", "by", "语句" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/Lib/DbConnection.php#L1210-L1221
walkor/GatewayWorker
src/Lib/DbConnection.php
DbConnection.buildLimit
protected function buildLimit() { $has_limit = $this->type == 'DELETE' || $this->type == 'UPDATE'; $has_offset = $this->type == 'SELECT'; if ($has_offset && $this->limit) { $clause = " LIMIT {$this->limit}"; if ($this->offset) { $clause .= " OFFSET {...
php
protected function buildLimit() { $has_limit = $this->type == 'DELETE' || $this->type == 'UPDATE'; $has_offset = $this->type == 'SELECT'; if ($has_offset && $this->limit) { $clause = " LIMIT {$this->limit}"; if ($this->offset) { $clause .= " OFFSET {...
[ "protected", "function", "buildLimit", "(", ")", "{", "$", "has_limit", "=", "$", "this", "->", "type", "==", "'DELETE'", "||", "$", "this", "->", "type", "==", "'UPDATE'", ";", "$", "has_offset", "=", "$", "this", "->", "type", "==", "'SELECT'", ";", ...
生成 limit 语句 @return string
[ "生成", "limit", "语句" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/Lib/DbConnection.php#L1228-L1243
walkor/GatewayWorker
src/Lib/DbConnection.php
DbConnection.quoteName
public function quoteName($spec) { $spec = trim($spec); $seps = array(' AS ', ' ', '.'); foreach ($seps as $sep) { $pos = strripos($spec, $sep); if ($pos) { return $this->quoteNameWithSeparator($spec, $sep, $pos); } } return...
php
public function quoteName($spec) { $spec = trim($spec); $seps = array(' AS ', ' ', '.'); foreach ($seps as $sep) { $pos = strripos($spec, $sep); if ($pos) { return $this->quoteNameWithSeparator($spec, $sep, $pos); } } return...
[ "public", "function", "quoteName", "(", "$", "spec", ")", "{", "$", "spec", "=", "trim", "(", "$", "spec", ")", ";", "$", "seps", "=", "array", "(", "' AS '", ",", "' '", ",", "'.'", ")", ";", "foreach", "(", "$", "seps", "as", "$", "sep", ")",...
Quotes @param string $spec @return string|array
[ "Quotes" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/Lib/DbConnection.php#L1251-L1262
walkor/GatewayWorker
src/Lib/DbConnection.php
DbConnection.quoteNameWithSeparator
protected function quoteNameWithSeparator($spec, $sep, $pos) { $len = strlen($sep); $part1 = $this->quoteName(substr($spec, 0, $pos)); $part2 = $this->replaceName(substr($spec, $pos + $len)); return "{$part1}{$sep}{$part2}"; }
php
protected function quoteNameWithSeparator($spec, $sep, $pos) { $len = strlen($sep); $part1 = $this->quoteName(substr($spec, 0, $pos)); $part2 = $this->replaceName(substr($spec, $pos + $len)); return "{$part1}{$sep}{$part2}"; }
[ "protected", "function", "quoteNameWithSeparator", "(", "$", "spec", ",", "$", "sep", ",", "$", "pos", ")", "{", "$", "len", "=", "strlen", "(", "$", "sep", ")", ";", "$", "part1", "=", "$", "this", "->", "quoteName", "(", "substr", "(", "$", "spec...
指定分隔符的 Quotes @param string $spec @param string $sep @param int $pos @return string
[ "指定分隔符的", "Quotes" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/Lib/DbConnection.php#L1272-L1278
walkor/GatewayWorker
src/Lib/DbConnection.php
DbConnection.quoteNamesInLoop
protected function quoteNamesInLoop($val, $is_last) { if ($is_last) { return $this->replaceNamesAndAliasIn($val); } return $this->replaceNamesIn($val); }
php
protected function quoteNamesInLoop($val, $is_last) { if ($is_last) { return $this->replaceNamesAndAliasIn($val); } return $this->replaceNamesIn($val); }
[ "protected", "function", "quoteNamesInLoop", "(", "$", "val", ",", "$", "is_last", ")", "{", "if", "(", "$", "is_last", ")", "{", "return", "$", "this", "->", "replaceNamesAndAliasIn", "(", "$", "val", ")", ";", "}", "return", "$", "this", "->", "repla...
循环 quote @param string $val @param bool $is_last @return string
[ "循环", "quote" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/Lib/DbConnection.php#L1324-L1330
walkor/GatewayWorker
src/Lib/DbConnection.php
DbConnection.replaceNamesAndAliasIn
protected function replaceNamesAndAliasIn($val) { $quoted = $this->replaceNamesIn($val); $pos = strripos($quoted, ' AS '); if ($pos) { $alias = $this->replaceName(substr($quoted, $pos + 4)); $quoted = substr($quoted, 0, $pos) . " AS $alias"; } retu...
php
protected function replaceNamesAndAliasIn($val) { $quoted = $this->replaceNamesIn($val); $pos = strripos($quoted, ' AS '); if ($pos) { $alias = $this->replaceName(substr($quoted, $pos + 4)); $quoted = substr($quoted, 0, $pos) . " AS $alias"; } retu...
[ "protected", "function", "replaceNamesAndAliasIn", "(", "$", "val", ")", "{", "$", "quoted", "=", "$", "this", "->", "replaceNamesIn", "(", "$", "val", ")", ";", "$", "pos", "=", "strripos", "(", "$", "quoted", ",", "' AS '", ")", ";", "if", "(", "$"...
替换成别名 @param string $val @return string
[ "替换成别名" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/Lib/DbConnection.php#L1338-L1347
walkor/GatewayWorker
src/Lib/DbConnection.php
DbConnection.replaceNamesIn
protected function replaceNamesIn($text) { $is_string_literal = strpos($text, "'") !== false || strpos($text, '"') !== false; if ($is_string_literal) { return $text; } $word = '[a-z_][a-z0-9_]+'; $find = "/(\\b)($word)\\.($word)(\\b)/i"; $re...
php
protected function replaceNamesIn($text) { $is_string_literal = strpos($text, "'") !== false || strpos($text, '"') !== false; if ($is_string_literal) { return $text; } $word = '[a-z_][a-z0-9_]+'; $find = "/(\\b)($word)\\.($word)(\\b)/i"; $re...
[ "protected", "function", "replaceNamesIn", "(", "$", "text", ")", "{", "$", "is_string_literal", "=", "strpos", "(", "$", "text", ",", "\"'\"", ")", "!==", "false", "||", "strpos", "(", "$", "text", ",", "'\"'", ")", "!==", "false", ";", "if", "(", "...
Quotes @param string $text @return string|array
[ "Quotes" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/Lib/DbConnection.php#L1370-L1387
walkor/GatewayWorker
src/Lib/DbConnection.php
DbConnection.getLastInsertIdName
public function getLastInsertIdName($col) { $key = str_replace('`', '', $this->table) . '.' . $col; if (isset($this->last_insert_id_names[$key])) { return $this->last_insert_id_names[$key]; } return null; }
php
public function getLastInsertIdName($col) { $key = str_replace('`', '', $this->table) . '.' . $col; if (isset($this->last_insert_id_names[$key])) { return $this->last_insert_id_names[$key]; } return null; }
[ "public", "function", "getLastInsertIdName", "(", "$", "col", ")", "{", "$", "key", "=", "str_replace", "(", "'`'", ",", "''", ",", "$", "this", "->", "table", ")", ".", "'.'", ".", "$", "col", ";", "if", "(", "isset", "(", "$", "this", "->", "la...
PDO::lastInsertId() @param string $col @return mixed
[ "PDO", "::", "lastInsertId", "()" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/Lib/DbConnection.php#L1442-L1450
walkor/GatewayWorker
src/Lib/DbConnection.php
DbConnection.cols
public function cols(array $cols) { if ($this->type == 'SELECT') { foreach ($cols as $key => $val) { $this->addColSELECT($key, $val); } return $this; } return $this->addCols($cols); }
php
public function cols(array $cols) { if ($this->type == 'SELECT') { foreach ($cols as $key => $val) { $this->addColSELECT($key, $val); } return $this; } return $this->addCols($cols); }
[ "public", "function", "cols", "(", "array", "$", "cols", ")", "{", "if", "(", "$", "this", "->", "type", "==", "'SELECT'", ")", "{", "foreach", "(", "$", "cols", "as", "$", "key", "=>", "$", "val", ")", "{", "$", "this", "->", "addColSELECT", "("...
设置多列 @param array $cols @return self
[ "设置多列" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/Lib/DbConnection.php#L1469-L1478
walkor/GatewayWorker
src/Lib/DbConnection.php
DbConnection.buildValuesForInsert
protected function buildValuesForInsert() { return ' (' . $this->indentCsv(array_keys($this->col_values)) . ') VALUES (' . $this->indentCsv(array_values($this->col_values)) . ')'; }
php
protected function buildValuesForInsert() { return ' (' . $this->indentCsv(array_keys($this->col_values)) . ') VALUES (' . $this->indentCsv(array_values($this->col_values)) . ')'; }
[ "protected", "function", "buildValuesForInsert", "(", ")", "{", "return", "' ('", ".", "$", "this", "->", "indentCsv", "(", "array_keys", "(", "$", "this", "->", "col_values", ")", ")", ".", "') VALUES ('", ".", "$", "this", "->", "indentCsv", "(", "array_...
为 INSERT 语句绑定值 @return string
[ "为", "INSERT", "语句绑定值" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/Lib/DbConnection.php#L1497-L1501
walkor/GatewayWorker
src/Lib/DbConnection.php
DbConnection.build
protected function build() { switch ($this->type) { case 'DELETE': return $this->buildDELETE(); case 'INSERT': return $this->buildINSERT(); case 'UPDATE': return $this->buildUPDATE(); case 'SELECT': ...
php
protected function build() { switch ($this->type) { case 'DELETE': return $this->buildDELETE(); case 'INSERT': return $this->buildINSERT(); case 'UPDATE': return $this->buildUPDATE(); case 'SELECT': ...
[ "protected", "function", "build", "(", ")", "{", "switch", "(", "$", "this", "->", "type", ")", "{", "case", "'DELETE'", ":", "return", "$", "this", "->", "buildDELETE", "(", ")", ";", "case", "'INSERT'", ":", "return", "$", "this", "->", "buildINSERT"...
生成完整 SQL 语句 @return string @throws Exception
[ "生成完整", "SQL", "语句" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/Lib/DbConnection.php#L1522-L1535
walkor/GatewayWorker
src/Lib/DbConnection.php
DbConnection.buildUPDATE
protected function buildUPDATE() { return 'UPDATE' . $this->buildFlags() . $this->buildTable() . $this->buildValuesForUpdate() . $this->buildWhere() . $this->buildOrderBy() . $this->buildLimit() . $this->buildReturning(); }
php
protected function buildUPDATE() { return 'UPDATE' . $this->buildFlags() . $this->buildTable() . $this->buildValuesForUpdate() . $this->buildWhere() . $this->buildOrderBy() . $this->buildLimit() . $this->buildReturning(); }
[ "protected", "function", "buildUPDATE", "(", ")", "{", "return", "'UPDATE'", ".", "$", "this", "->", "buildFlags", "(", ")", ".", "$", "this", "->", "buildTable", "(", ")", ".", "$", "this", "->", "buildValuesForUpdate", "(", ")", ".", "$", "this", "->...
生成更新的 SQL 语句
[ "生成更新的", "SQL", "语句" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/Lib/DbConnection.php#L1540-L1550
walkor/GatewayWorker
src/Lib/DbConnection.php
DbConnection.buildValuesForUpdate
protected function buildValuesForUpdate() { $values = array(); foreach ($this->col_values as $col => $value) { $values[] = "{$col} = {$value}"; } return ' SET' . $this->indentCsv($values); }
php
protected function buildValuesForUpdate() { $values = array(); foreach ($this->col_values as $col => $value) { $values[] = "{$col} = {$value}"; } return ' SET' . $this->indentCsv($values); }
[ "protected", "function", "buildValuesForUpdate", "(", ")", "{", "$", "values", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "col_values", "as", "$", "col", "=>", "$", "value", ")", "{", "$", "values", "[", "]", "=", "\"{$col} = {$val...
为更新语句绑定值 @return string
[ "为更新语句绑定值" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/Lib/DbConnection.php#L1567-L1574
walkor/GatewayWorker
src/Lib/DbConnection.php
DbConnection.getBindValuesCOMMON
public function getBindValuesCOMMON() { $bind_values = $this->bind_values; $i = 1; foreach ($this->bind_where as $val) { $bind_values[$i] = $val; $i++; } return $bind_values; }
php
public function getBindValuesCOMMON() { $bind_values = $this->bind_values; $i = 1; foreach ($this->bind_where as $val) { $bind_values[$i] = $val; $i++; } return $bind_values; }
[ "public", "function", "getBindValuesCOMMON", "(", ")", "{", "$", "bind_values", "=", "$", "this", "->", "bind_values", ";", "$", "i", "=", "1", ";", "foreach", "(", "$", "this", "->", "bind_where", "as", "$", "val", ")", "{", "$", "bind_values", "[", ...
获取绑定的值 @return array
[ "获取绑定的值" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/Lib/DbConnection.php#L1582-L1591
walkor/GatewayWorker
src/Lib/DbConnection.php
DbConnection.addCol
protected function addCol($col) { $key = $this->quoteName($col); $this->col_values[$key] = ":$col"; $args = func_get_args(); if (count($args) > 1) { $this->bindValue($col, $args[1]); } return $this; }
php
protected function addCol($col) { $key = $this->quoteName($col); $this->col_values[$key] = ":$col"; $args = func_get_args(); if (count($args) > 1) { $this->bindValue($col, $args[1]); } return $this; }
[ "protected", "function", "addCol", "(", "$", "col", ")", "{", "$", "key", "=", "$", "this", "->", "quoteName", "(", "$", "col", ")", ";", "$", "this", "->", "col_values", "[", "$", "key", "]", "=", "\":$col\"", ";", "$", "args", "=", "func_get_args...
设置列 @param string $col @return self
[ "设置列" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/Lib/DbConnection.php#L1599-L1608
walkor/GatewayWorker
src/Lib/DbConnection.php
DbConnection.addCols
protected function addCols(array $cols) { foreach ($cols as $key => $val) { if (is_int($key)) { $this->addCol($val); } else { $this->addCol($key, $val); } } return $this; }
php
protected function addCols(array $cols) { foreach ($cols as $key => $val) { if (is_int($key)) { $this->addCol($val); } else { $this->addCol($key, $val); } } return $this; }
[ "protected", "function", "addCols", "(", "array", "$", "cols", ")", "{", "foreach", "(", "$", "cols", "as", "$", "key", "=>", "$", "val", ")", "{", "if", "(", "is_int", "(", "$", "key", ")", ")", "{", "$", "this", "->", "addCol", "(", "$", "val...
设置多个列 @param array $cols @return self
[ "设置多个列" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/Lib/DbConnection.php#L1616-L1626
walkor/GatewayWorker
src/Lib/DbConnection.php
DbConnection.setCol
protected function setCol($col, $value) { if ($value === null) { $value = 'NULL'; } $key = $this->quoteName($col); $value = $this->quoteNamesIn($value); $this->col_values[$key] = $value; return $this; }
php
protected function setCol($col, $value) { if ($value === null) { $value = 'NULL'; } $key = $this->quoteName($col); $value = $this->quoteNamesIn($value); $this->col_values[$key] = $value; return $this; }
[ "protected", "function", "setCol", "(", "$", "col", ",", "$", "value", ")", "{", "if", "(", "$", "value", "===", "null", ")", "{", "$", "value", "=", "'NULL'", ";", "}", "$", "key", "=", "$", "this", "->", "quoteName", "(", "$", "col", ")", ";"...
设置单列的值 @param string $col . @param string $value @return self
[ "设置单列的值" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/Lib/DbConnection.php#L1635-L1645
walkor/GatewayWorker
src/Lib/DbConnection.php
DbConnection.addReturning
protected function addReturning(array $cols) { foreach ($cols as $col) { $this->returning[] = $this->quoteNamesIn($col); } return $this; }
php
protected function addReturning(array $cols) { foreach ($cols as $col) { $this->returning[] = $this->quoteNamesIn($col); } return $this; }
[ "protected", "function", "addReturning", "(", "array", "$", "cols", ")", "{", "foreach", "(", "$", "cols", "as", "$", "col", ")", "{", "$", "this", "->", "returning", "[", "]", "=", "$", "this", "->", "quoteNamesIn", "(", "$", "col", ")", ";", "}",...
增加返回的列 @param array $cols @return self
[ "增加返回的列" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/Lib/DbConnection.php#L1654-L1660
walkor/GatewayWorker
src/Lib/DbConnection.php
DbConnection.connect
protected function connect() { $dsn = 'mysql:dbname=' . $this->settings["dbname"] . ';host=' . $this->settings["host"] . ';port=' . $this->settings['port']; $this->pdo = new PDO($dsn, $this->settings["user"], $this->settings["password"], array( PDO::MYSQ...
php
protected function connect() { $dsn = 'mysql:dbname=' . $this->settings["dbname"] . ';host=' . $this->settings["host"] . ';port=' . $this->settings['port']; $this->pdo = new PDO($dsn, $this->settings["user"], $this->settings["password"], array( PDO::MYSQ...
[ "protected", "function", "connect", "(", ")", "{", "$", "dsn", "=", "'mysql:dbname='", ".", "$", "this", "->", "settings", "[", "\"dbname\"", "]", ".", "';host='", ".", "$", "this", "->", "settings", "[", "\"host\"", "]", ".", "';port='", ".", "$", "th...
创建 PDO 实例
[ "创建", "PDO", "实例" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/Lib/DbConnection.php#L1701-L1713
walkor/GatewayWorker
src/Lib/DbConnection.php
DbConnection.execute
protected function execute($query, $parameters = "") { try { $this->sQuery = @$this->pdo->prepare($query); $this->bindMore($parameters); if (!empty($this->parameters)) { foreach ($this->parameters as $param) { $parameters = explode("\x7...
php
protected function execute($query, $parameters = "") { try { $this->sQuery = @$this->pdo->prepare($query); $this->bindMore($parameters); if (!empty($this->parameters)) { foreach ($this->parameters as $param) { $parameters = explode("\x7...
[ "protected", "function", "execute", "(", "$", "query", ",", "$", "parameters", "=", "\"\"", ")", "{", "try", "{", "$", "this", "->", "sQuery", "=", "@", "$", "this", "->", "pdo", "->", "prepare", "(", "$", "query", ")", ";", "$", "this", "->", "b...
执行 @param string $query @param string $parameters @throws PDOException
[ "执行" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/Lib/DbConnection.php#L1730-L1771
walkor/GatewayWorker
src/Lib/DbConnection.php
DbConnection.bind
public function bind($para, $value) { if (is_string($para)) { $this->parameters[sizeof($this->parameters)] = ":" . $para . "\x7F" . $value; } else { $this->parameters[sizeof($this->parameters)] = $para . "\x7F" . $value; } }
php
public function bind($para, $value) { if (is_string($para)) { $this->parameters[sizeof($this->parameters)] = ":" . $para . "\x7F" . $value; } else { $this->parameters[sizeof($this->parameters)] = $para . "\x7F" . $value; } }
[ "public", "function", "bind", "(", "$", "para", ",", "$", "value", ")", "{", "if", "(", "is_string", "(", "$", "para", ")", ")", "{", "$", "this", "->", "parameters", "[", "sizeof", "(", "$", "this", "->", "parameters", ")", "]", "=", "\":\"", "....
绑定 @param string $para @param string $value
[ "绑定" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/Lib/DbConnection.php#L1779-L1786
walkor/GatewayWorker
src/Lib/DbConnection.php
DbConnection.bindMore
public function bindMore($parray) { if (empty($this->parameters) && is_array($parray)) { $columns = array_keys($parray); foreach ($columns as $i => &$column) { $this->bind($column, $parray[$column]); } } }
php
public function bindMore($parray) { if (empty($this->parameters) && is_array($parray)) { $columns = array_keys($parray); foreach ($columns as $i => &$column) { $this->bind($column, $parray[$column]); } } }
[ "public", "function", "bindMore", "(", "$", "parray", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "parameters", ")", "&&", "is_array", "(", "$", "parray", ")", ")", "{", "$", "columns", "=", "array_keys", "(", "$", "parray", ")", ";", "fo...
绑定多个 @param array $parray
[ "绑定多个" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/Lib/DbConnection.php#L1793-L1801
walkor/GatewayWorker
src/Lib/DbConnection.php
DbConnection.query
public function query($query = '', $params = null, $fetchmode = PDO::FETCH_ASSOC) { $query = trim($query); if (empty($query)) { $query = $this->build(); if (!$params) { $params = $this->getBindValues(); } } $this->resetAll(); ...
php
public function query($query = '', $params = null, $fetchmode = PDO::FETCH_ASSOC) { $query = trim($query); if (empty($query)) { $query = $this->build(); if (!$params) { $params = $this->getBindValues(); } } $this->resetAll(); ...
[ "public", "function", "query", "(", "$", "query", "=", "''", ",", "$", "params", "=", "null", ",", "$", "fetchmode", "=", "PDO", "::", "FETCH_ASSOC", ")", "{", "$", "query", "=", "trim", "(", "$", "query", ")", ";", "if", "(", "empty", "(", "$", ...
执行 SQL @param string $query @param array $params @param int $fetchmode @return mixed
[ "执行", "SQL" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/Lib/DbConnection.php#L1811-L1842
walkor/GatewayWorker
src/Lib/DbConnection.php
DbConnection.column
public function column($query = '', $params = null) { $query = trim($query); if (empty($query)) { $query = $this->build(); if (!$params) { $params = $this->getBindValues(); } } $this->resetAll(); $this->lastSql = $query; ...
php
public function column($query = '', $params = null) { $query = trim($query); if (empty($query)) { $query = $this->build(); if (!$params) { $params = $this->getBindValues(); } } $this->resetAll(); $this->lastSql = $query; ...
[ "public", "function", "column", "(", "$", "query", "=", "''", ",", "$", "params", "=", "null", ")", "{", "$", "query", "=", "trim", "(", "$", "query", ")", ";", "if", "(", "empty", "(", "$", "query", ")", ")", "{", "$", "query", "=", "$", "th...
返回一列 @param string $query @param array $params @return array
[ "返回一列" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/Lib/DbConnection.php#L1851-L1871
walkor/GatewayWorker
src/Lib/DbConnection.php
DbConnection.row
public function row($query = '', $params = null, $fetchmode = PDO::FETCH_ASSOC) { $query = trim($query); if (empty($query)) { $query = $this->build(); if (!$params) { $params = $this->getBindValues(); } } $this->resetAll(); ...
php
public function row($query = '', $params = null, $fetchmode = PDO::FETCH_ASSOC) { $query = trim($query); if (empty($query)) { $query = $this->build(); if (!$params) { $params = $this->getBindValues(); } } $this->resetAll(); ...
[ "public", "function", "row", "(", "$", "query", "=", "''", ",", "$", "params", "=", "null", ",", "$", "fetchmode", "=", "PDO", "::", "FETCH_ASSOC", ")", "{", "$", "query", "=", "trim", "(", "$", "query", ")", ";", "if", "(", "empty", "(", "$", ...
返回一行 @param string $query @param array $params @param int $fetchmode @return array
[ "返回一行" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/Lib/DbConnection.php#L1881-L1896
walkor/GatewayWorker
src/Lib/DbConnection.php
DbConnection.single
public function single($query = '', $params = null) { $query = trim($query); if (empty($query)) { $query = $this->build(); if (!$params) { $params = $this->getBindValues(); } } $this->resetAll(); $this->lastSql = $query; ...
php
public function single($query = '', $params = null) { $query = trim($query); if (empty($query)) { $query = $this->build(); if (!$params) { $params = $this->getBindValues(); } } $this->resetAll(); $this->lastSql = $query; ...
[ "public", "function", "single", "(", "$", "query", "=", "''", ",", "$", "params", "=", "null", ")", "{", "$", "query", "=", "trim", "(", "$", "query", ")", ";", "if", "(", "empty", "(", "$", "query", ")", ")", "{", "$", "query", "=", "$", "th...
返回单个值 @param string $query @param array $params @return string
[ "返回单个值" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/Lib/DbConnection.php#L1905-L1920
walkor/GatewayWorker
src/Lib/DbConnection.php
DbConnection.beginTrans
public function beginTrans() { try { $this->pdo->beginTransaction(); } catch (PDOException $e) { // 服务端断开时重连一次 if ($e->errorInfo[1] == 2006 || $e->errorInfo[1] == 2013) { $this->pdo->beginTransaction(); } else { throw $e...
php
public function beginTrans() { try { $this->pdo->beginTransaction(); } catch (PDOException $e) { // 服务端断开时重连一次 if ($e->errorInfo[1] == 2006 || $e->errorInfo[1] == 2013) { $this->pdo->beginTransaction(); } else { throw $e...
[ "public", "function", "beginTrans", "(", ")", "{", "try", "{", "$", "this", "->", "pdo", "->", "beginTransaction", "(", ")", ";", "}", "catch", "(", "PDOException", "$", "e", ")", "{", "// 服务端断开时重连一次", "if", "(", "$", "e", "->", "errorInfo", "[", "1"...
开始事务
[ "开始事务" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/Lib/DbConnection.php#L1945-L1957
walkor/GatewayWorker
src/Register.php
Register.run
public function run() { // 设置 onMessage 连接回调 $this->onConnect = array($this, 'onConnect'); // 设置 onMessage 回调 $this->onMessage = array($this, 'onMessage'); // 设置 onClose 回调 $this->onClose = array($this, 'onClose'); // 记录进程启动的时间 $this->_startTime = t...
php
public function run() { // 设置 onMessage 连接回调 $this->onConnect = array($this, 'onConnect'); // 设置 onMessage 回调 $this->onMessage = array($this, 'onMessage'); // 设置 onClose 回调 $this->onClose = array($this, 'onClose'); // 记录进程启动的时间 $this->_startTime = t...
[ "public", "function", "run", "(", ")", "{", "// 设置 onMessage 连接回调", "$", "this", "->", "onConnect", "=", "array", "(", "$", "this", ",", "'onConnect'", ")", ";", "// 设置 onMessage 回调", "$", "this", "->", "onMessage", "=", "array", "(", "$", "this", ",", "...
{@inheritdoc}
[ "{" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/Register.php#L68-L87
walkor/GatewayWorker
src/Register.php
Register.onConnect
public function onConnect($connection) { $connection->timeout_timerid = Timer::add(10, function () use ($connection) { Worker::log("Register auth timeout (".$connection->getRemoteIp()."). See http://wiki.workerman.net/Error4 for detail"); $connection->close(); }, null, false)...
php
public function onConnect($connection) { $connection->timeout_timerid = Timer::add(10, function () use ($connection) { Worker::log("Register auth timeout (".$connection->getRemoteIp()."). See http://wiki.workerman.net/Error4 for detail"); $connection->close(); }, null, false)...
[ "public", "function", "onConnect", "(", "$", "connection", ")", "{", "$", "connection", "->", "timeout_timerid", "=", "Timer", "::", "add", "(", "10", ",", "function", "(", ")", "use", "(", "$", "connection", ")", "{", "Worker", "::", "log", "(", "\"Re...
设置个定时器,将未及时发送验证的连接关闭 @param \Workerman\Connection\ConnectionInterface $connection @return void
[ "设置个定时器,将未及时发送验证的连接关闭" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/Register.php#L95-L101
walkor/GatewayWorker
src/Register.php
Register.onMessage
public function onMessage($connection, $buffer) { // 删除定时器 Timer::del($connection->timeout_timerid); $data = @json_decode($buffer, true); if (empty($data['event'])) { $error = "Bad request for Register service. Request info(IP:".$connection->getRemoteIp().", Request...
php
public function onMessage($connection, $buffer) { // 删除定时器 Timer::del($connection->timeout_timerid); $data = @json_decode($buffer, true); if (empty($data['event'])) { $error = "Bad request for Register service. Request info(IP:".$connection->getRemoteIp().", Request...
[ "public", "function", "onMessage", "(", "$", "connection", ",", "$", "buffer", ")", "{", "// 删除定时器", "Timer", "::", "del", "(", "$", "connection", "->", "timeout_timerid", ")", ";", "$", "data", "=", "@", "json_decode", "(", "$", "buffer", ",", "true", ...
设置消息回调 @param \Workerman\Connection\ConnectionInterface $connection @param string $buffer @return void
[ "设置消息回调" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/Register.php#L110-L152
walkor/GatewayWorker
src/Register.php
Register.onClose
public function onClose($connection) { if (isset($this->_gatewayConnections[$connection->id])) { unset($this->_gatewayConnections[$connection->id]); $this->broadcastAddresses(); } if (isset($this->_workerConnections[$connection->id])) { unset($this->_worke...
php
public function onClose($connection) { if (isset($this->_gatewayConnections[$connection->id])) { unset($this->_gatewayConnections[$connection->id]); $this->broadcastAddresses(); } if (isset($this->_workerConnections[$connection->id])) { unset($this->_worke...
[ "public", "function", "onClose", "(", "$", "connection", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "_gatewayConnections", "[", "$", "connection", "->", "id", "]", ")", ")", "{", "unset", "(", "$", "this", "->", "_gatewayConnections", "[", "...
连接关闭时 @param \Workerman\Connection\ConnectionInterface $connection
[ "连接关闭时" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/Register.php#L159-L168
walkor/GatewayWorker
src/Register.php
Register.broadcastAddresses
public function broadcastAddresses($connection = null) { $data = array( 'event' => 'broadcast_addresses', 'addresses' => array_unique(array_values($this->_gatewayConnections)), ); $buffer = json_encode($data); if ($connection) { $connection->...
php
public function broadcastAddresses($connection = null) { $data = array( 'event' => 'broadcast_addresses', 'addresses' => array_unique(array_values($this->_gatewayConnections)), ); $buffer = json_encode($data); if ($connection) { $connection->...
[ "public", "function", "broadcastAddresses", "(", "$", "connection", "=", "null", ")", "{", "$", "data", "=", "array", "(", "'event'", "=>", "'broadcast_addresses'", ",", "'addresses'", "=>", "array_unique", "(", "array_values", "(", "$", "this", "->", "_gatewa...
向 BusinessWorker 广播 gateway 内部通讯地址 @param \Workerman\Connection\ConnectionInterface $connection
[ "向", "BusinessWorker", "广播", "gateway", "内部通讯地址" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/Register.php#L175-L189
walkor/GatewayWorker
src/Lib/Context.php
Context.clear
public static function clear() { self::$local_ip = self::$local_port = self::$client_ip = self::$client_port = self::$client_id = self::$connection_id = self::$old_session = null; }
php
public static function clear() { self::$local_ip = self::$local_port = self::$client_ip = self::$client_port = self::$client_id = self::$connection_id = self::$old_session = null; }
[ "public", "static", "function", "clear", "(", ")", "{", "self", "::", "$", "local_ip", "=", "self", "::", "$", "local_port", "=", "self", "::", "$", "client_ip", "=", "self", "::", "$", "client_port", "=", "self", "::", "$", "client_id", "=", "self", ...
清除上下文 @return void
[ "清除上下文" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/Lib/Context.php#L102-L106
walkor/GatewayWorker
src/Gateway.php
Gateway.onClientMessage
public function onClientMessage($connection, $data) { $connection->pingNotResponseCount = -1; $this->sendToWorker(GatewayProtocol::CMD_ON_MESSAGE, $connection, $data); }
php
public function onClientMessage($connection, $data) { $connection->pingNotResponseCount = -1; $this->sendToWorker(GatewayProtocol::CMD_ON_MESSAGE, $connection, $data); }
[ "public", "function", "onClientMessage", "(", "$", "connection", ",", "$", "data", ")", "{", "$", "connection", "->", "pingNotResponseCount", "=", "-", "1", ";", "$", "this", "->", "sendToWorker", "(", "GatewayProtocol", "::", "CMD_ON_MESSAGE", ",", "$", "co...
当客户端发来数据时,转发给worker处理 @param TcpConnection $connection @param mixed $data
[ "当客户端发来数据时,转发给worker处理" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/Gateway.php#L285-L289
walkor/GatewayWorker
src/Gateway.php
Gateway.onWebsocketConnect
public function onWebsocketConnect($connection, $http_buffer) { $this->sendToWorker(GatewayProtocol::CMD_ON_WEBSOCKET_CONNECT, $connection, array('get' => $_GET, 'server' => $_SERVER, 'cookie' => $_COOKIE)); }
php
public function onWebsocketConnect($connection, $http_buffer) { $this->sendToWorker(GatewayProtocol::CMD_ON_WEBSOCKET_CONNECT, $connection, array('get' => $_GET, 'server' => $_SERVER, 'cookie' => $_COOKIE)); }
[ "public", "function", "onWebsocketConnect", "(", "$", "connection", ",", "$", "http_buffer", ")", "{", "$", "this", "->", "sendToWorker", "(", "GatewayProtocol", "::", "CMD_ON_WEBSOCKET_CONNECT", ",", "$", "connection", ",", "array", "(", "'get'", "=>", "$", "...
websocket握手时触发 @param $connection @param $http_buffer
[ "websocket握手时触发" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/Gateway.php#L335-L338
walkor/GatewayWorker
src/Gateway.php
Gateway.generateConnectionId
protected function generateConnectionId() { $max_unsigned_int = 4294967295; if (self::$_connectionIdRecorder >= $max_unsigned_int) { self::$_connectionIdRecorder = 0; } while(++self::$_connectionIdRecorder <= $max_unsigned_int) { if(!isset($this->_clientConnec...
php
protected function generateConnectionId() { $max_unsigned_int = 4294967295; if (self::$_connectionIdRecorder >= $max_unsigned_int) { self::$_connectionIdRecorder = 0; } while(++self::$_connectionIdRecorder <= $max_unsigned_int) { if(!isset($this->_clientConnec...
[ "protected", "function", "generateConnectionId", "(", ")", "{", "$", "max_unsigned_int", "=", "4294967295", ";", "if", "(", "self", "::", "$", "_connectionIdRecorder", ">=", "$", "max_unsigned_int", ")", "{", "self", "::", "$", "_connectionIdRecorder", "=", "0",...
生成connection id @return int
[ "生成connection", "id" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/Gateway.php#L344-L356
walkor/GatewayWorker
src/Gateway.php
Gateway.sendToWorker
protected function sendToWorker($cmd, $connection, $body = '') { $gateway_data = $connection->gatewayHeader; $gateway_data['cmd'] = $cmd; $gateway_data['body'] = $body; $gateway_data['ext_data'] = $connection->session; if ($this->_workerConnections) { ...
php
protected function sendToWorker($cmd, $connection, $body = '') { $gateway_data = $connection->gatewayHeader; $gateway_data['cmd'] = $cmd; $gateway_data['body'] = $body; $gateway_data['ext_data'] = $connection->session; if ($this->_workerConnections) { ...
[ "protected", "function", "sendToWorker", "(", "$", "cmd", ",", "$", "connection", ",", "$", "body", "=", "''", ")", "{", "$", "gateway_data", "=", "$", "connection", "->", "gatewayHeader", ";", "$", "gateway_data", "[", "'cmd'", "]", "=", "$", "cmd", "...
发送数据给 worker 进程 @param int $cmd @param TcpConnection $connection @param mixed $body @return bool
[ "发送数据给", "worker", "进程" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/Gateway.php#L366-L394
walkor/GatewayWorker
src/Gateway.php
Gateway.routerBind
public static function routerBind($worker_connections, $client_connection, $cmd, $buffer) { if (!isset($client_connection->businessworker_address) || !isset($worker_connections[$client_connection->businessworker_address])) { $client_connection->businessworker_address = array_rand($worker_connect...
php
public static function routerBind($worker_connections, $client_connection, $cmd, $buffer) { if (!isset($client_connection->businessworker_address) || !isset($worker_connections[$client_connection->businessworker_address])) { $client_connection->businessworker_address = array_rand($worker_connect...
[ "public", "static", "function", "routerBind", "(", "$", "worker_connections", ",", "$", "client_connection", ",", "$", "cmd", ",", "$", "buffer", ")", "{", "if", "(", "!", "isset", "(", "$", "client_connection", "->", "businessworker_address", ")", "||", "!"...
client_id 与 worker 绑定 @param array $worker_connections @param TcpConnection $client_connection @param int $cmd @param mixed $buffer @return TcpConnection
[ "client_id", "与", "worker", "绑定" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/Gateway.php#L419-L425
walkor/GatewayWorker
src/Gateway.php
Gateway.onClientClose
public function onClientClose($connection) { // 尝试通知 worker,触发 Event::onClose $this->sendToWorker(GatewayProtocol::CMD_ON_CLOSE, $connection); unset($this->_clientConnections[$connection->id]); // 清理 uid 数据 if (!empty($connection->uid)) { $uid = $connection->uid; ...
php
public function onClientClose($connection) { // 尝试通知 worker,触发 Event::onClose $this->sendToWorker(GatewayProtocol::CMD_ON_CLOSE, $connection); unset($this->_clientConnections[$connection->id]); // 清理 uid 数据 if (!empty($connection->uid)) { $uid = $connection->uid; ...
[ "public", "function", "onClientClose", "(", "$", "connection", ")", "{", "// 尝试通知 worker,触发 Event::onClose", "$", "this", "->", "sendToWorker", "(", "GatewayProtocol", "::", "CMD_ON_CLOSE", ",", "$", "connection", ")", ";", "unset", "(", "$", "this", "->", "_cli...
当客户端关闭时 @param TcpConnection $connection
[ "当客户端关闭时" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/Gateway.php#L432-L458
walkor/GatewayWorker
src/Gateway.php
Gateway.onWorkerStart
public function onWorkerStart() { // 分配一个内部通讯端口 $this->lanPort = $this->startPort + $this->id; // 如果有设置心跳,则定时执行 if ($this->pingInterval > 0) { $timer_interval = $this->pingNotResponseLimit > 0 ? $this->pingInterval / 2 : $this->pingInterval; Timer::add($timer...
php
public function onWorkerStart() { // 分配一个内部通讯端口 $this->lanPort = $this->startPort + $this->id; // 如果有设置心跳,则定时执行 if ($this->pingInterval > 0) { $timer_interval = $this->pingNotResponseLimit > 0 ? $this->pingInterval / 2 : $this->pingInterval; Timer::add($timer...
[ "public", "function", "onWorkerStart", "(", ")", "{", "// 分配一个内部通讯端口", "$", "this", "->", "lanPort", "=", "$", "this", "->", "startPort", "+", "$", "this", "->", "id", ";", "// 如果有设置心跳,则定时执行", "if", "(", "$", "this", "->", "pingInterval", ">", "0", ")", ...
当 Gateway 启动的时候触发的回调函数 @return void
[ "当", "Gateway", "启动的时候触发的回调函数" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/Gateway.php#L465-L505
walkor/GatewayWorker
src/Gateway.php
Gateway.onWorkerConnect
public function onWorkerConnect($connection) { $connection->maxSendBufferSize = $this->sendToWorkerBufferSize; $connection->authorized = $this->secretKey ? false : true; }
php
public function onWorkerConnect($connection) { $connection->maxSendBufferSize = $this->sendToWorkerBufferSize; $connection->authorized = $this->secretKey ? false : true; }
[ "public", "function", "onWorkerConnect", "(", "$", "connection", ")", "{", "$", "connection", "->", "maxSendBufferSize", "=", "$", "this", "->", "sendToWorkerBufferSize", ";", "$", "connection", "->", "authorized", "=", "$", "this", "->", "secretKey", "?", "fa...
当 worker 通过内部通讯端口连接到 gateway 时 @param TcpConnection $connection
[ "当", "worker", "通过内部通讯端口连接到", "gateway", "时" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/Gateway.php#L513-L517
walkor/GatewayWorker
src/Gateway.php
Gateway.registerAddress
public function registerAddress() { $address = $this->lanIp . ':' . $this->lanPort; foreach ($this->registerAddress as $register_address) { $register_connection = new AsyncTcpConnection("text://{$register_address}"); $secret_key = $this->secretKey; $register_conne...
php
public function registerAddress() { $address = $this->lanIp . ':' . $this->lanPort; foreach ($this->registerAddress as $register_address) { $register_connection = new AsyncTcpConnection("text://{$register_address}"); $secret_key = $this->secretKey; $register_conne...
[ "public", "function", "registerAddress", "(", ")", "{", "$", "address", "=", "$", "this", "->", "lanIp", ".", "':'", ".", "$", "this", "->", "lanPort", ";", "foreach", "(", "$", "this", "->", "registerAddress", "as", "$", "register_address", ")", "{", ...
存储当前 Gateway 的内部通信地址 @return bool
[ "存储当前", "Gateway", "的内部通信地址" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/Gateway.php#L910-L933
walkor/GatewayWorker
src/Gateway.php
Gateway.ping
public function ping() { $ping_data = $this->pingData ? (string)$this->pingData : null; $raw = false; if ($this->protocolAccelerate && $ping_data && $this->protocol) { $ping_data = $this->preEncodeForClient($ping_data); $raw = true; } // 遍历所有客户端连接 ...
php
public function ping() { $ping_data = $this->pingData ? (string)$this->pingData : null; $raw = false; if ($this->protocolAccelerate && $ping_data && $this->protocol) { $ping_data = $this->preEncodeForClient($ping_data); $raw = true; } // 遍历所有客户端连接 ...
[ "public", "function", "ping", "(", ")", "{", "$", "ping_data", "=", "$", "this", "->", "pingData", "?", "(", "string", ")", "$", "this", "->", "pingData", ":", "null", ";", "$", "raw", "=", "false", ";", "if", "(", "$", "this", "->", "protocolAccel...
心跳逻辑 @return void
[ "心跳逻辑" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/Gateway.php#L941-L969
walkor/GatewayWorker
src/Gateway.php
Gateway.pingBusinessWorker
public function pingBusinessWorker() { $gateway_data = GatewayProtocol::$empty; $gateway_data['cmd'] = GatewayProtocol::CMD_PING; foreach ($this->_workerConnections as $connection) { $connection->send($gateway_data); } }
php
public function pingBusinessWorker() { $gateway_data = GatewayProtocol::$empty; $gateway_data['cmd'] = GatewayProtocol::CMD_PING; foreach ($this->_workerConnections as $connection) { $connection->send($gateway_data); } }
[ "public", "function", "pingBusinessWorker", "(", ")", "{", "$", "gateway_data", "=", "GatewayProtocol", "::", "$", "empty", ";", "$", "gateway_data", "[", "'cmd'", "]", "=", "GatewayProtocol", "::", "CMD_PING", ";", "foreach", "(", "$", "this", "->", "_worke...
向 BusinessWorker 发送心跳数据,用于保持长连接 @return void
[ "向", "BusinessWorker", "发送心跳数据,用于保持长连接" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/Gateway.php#L976-L983
walkor/GatewayWorker
src/Gateway.php
Gateway.preEncodeForClient
protected function preEncodeForClient($data) { foreach ($this->_clientConnections as $client_connection) { return call_user_func(array($client_connection->protocol, 'encode'), $data, $client_connection); } }
php
protected function preEncodeForClient($data) { foreach ($this->_clientConnections as $client_connection) { return call_user_func(array($client_connection->protocol, 'encode'), $data, $client_connection); } }
[ "protected", "function", "preEncodeForClient", "(", "$", "data", ")", "{", "foreach", "(", "$", "this", "->", "_clientConnections", "as", "$", "client_connection", ")", "{", "return", "call_user_func", "(", "array", "(", "$", "client_connection", "->", "protocol...
@param mixed $data @return string
[ "@param", "mixed", "$data" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/Gateway.php#L990-L995
walkor/GatewayWorker
src/Gateway.php
Gateway.log
public static function log($msg){ Timer::add(1, function() use ($msg) { Worker::log($msg); }, null, false); }
php
public static function log($msg){ Timer::add(1, function() use ($msg) { Worker::log($msg); }, null, false); }
[ "public", "static", "function", "log", "(", "$", "msg", ")", "{", "Timer", "::", "add", "(", "1", ",", "function", "(", ")", "use", "(", "$", "msg", ")", "{", "Worker", "::", "log", "(", "$", "msg", ")", ";", "}", ",", "null", ",", "false", "...
Log. @param string $msg
[ "Log", "." ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/Gateway.php#L1014-L1018
walkor/GatewayWorker
src/Lib/Gateway.php
Gateway.getAllGatewayAddressesFromRegister
protected static function getAllGatewayAddressesFromRegister() { static $addresses_cache, $last_update; $time_now = time(); $expiration_time = 1; $register_addresses = (array)static::$registerAddress; if(empty($addresses_cache) || $time_now - $last_update > $expiration_time) ...
php
protected static function getAllGatewayAddressesFromRegister() { static $addresses_cache, $last_update; $time_now = time(); $expiration_time = 1; $register_addresses = (array)static::$registerAddress; if(empty($addresses_cache) || $time_now - $last_update > $expiration_time) ...
[ "protected", "static", "function", "getAllGatewayAddressesFromRegister", "(", ")", "{", "static", "$", "addresses_cache", ",", "$", "last_update", ";", "$", "time_now", "=", "time", "(", ")", ";", "$", "expiration_time", "=", "1", ";", "$", "register_addresses",...
获取通过注册中心获取所有 gateway 通讯地址 @return array @throws Exception
[ "获取通过注册中心获取所有", "gateway", "通讯地址" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/Lib/Gateway.php#L1309-L1341
walkor/GatewayWorker
src/BusinessWorker.php
BusinessWorker.run
public function run() { $this->_onWorkerStart = $this->onWorkerStart; $this->_onWorkerReload = $this->onWorkerReload; $this->_onWorkerStop = $this->onWorkerStop; $this->onWorkerStop = array($this, 'onWorkerStop'); $this->onWorkerStart = array($this, 'onWorkerStart'); ...
php
public function run() { $this->_onWorkerStart = $this->onWorkerStart; $this->_onWorkerReload = $this->onWorkerReload; $this->_onWorkerStop = $this->onWorkerStop; $this->onWorkerStop = array($this, 'onWorkerStop'); $this->onWorkerStart = array($this, 'onWorkerStart'); ...
[ "public", "function", "run", "(", ")", "{", "$", "this", "->", "_onWorkerStart", "=", "$", "this", "->", "onWorkerStart", ";", "$", "this", "->", "_onWorkerReload", "=", "$", "this", "->", "onWorkerReload", ";", "$", "this", "->", "_onWorkerStop", "=", "...
{@inheritdoc}
[ "{" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/BusinessWorker.php#L189-L198
walkor/GatewayWorker
src/BusinessWorker.php
BusinessWorker.onWorkerStart
protected function onWorkerStart() { if (!class_exists('\Protocols\GatewayProtocol')) { class_alias('GatewayWorker\Protocols\GatewayProtocol', 'Protocols\GatewayProtocol'); } if (!is_array($this->registerAddress)) { $this->registerAddress = array($this->registerAddre...
php
protected function onWorkerStart() { if (!class_exists('\Protocols\GatewayProtocol')) { class_alias('GatewayWorker\Protocols\GatewayProtocol', 'Protocols\GatewayProtocol'); } if (!is_array($this->registerAddress)) { $this->registerAddress = array($this->registerAddre...
[ "protected", "function", "onWorkerStart", "(", ")", "{", "if", "(", "!", "class_exists", "(", "'\\Protocols\\GatewayProtocol'", ")", ")", "{", "class_alias", "(", "'GatewayWorker\\Protocols\\GatewayProtocol'", ",", "'Protocols\\GatewayProtocol'", ")", ";", "}", "if", ...
当进程启动时一些初始化工作 @return void
[ "当进程启动时一些初始化工作" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/BusinessWorker.php#L205-L252
walkor/GatewayWorker
src/BusinessWorker.php
BusinessWorker.onWorkerReload
protected function onWorkerReload($worker) { // 防止进程立刻退出 $worker->reloadable = false; // 延迟 0.05 秒退出,避免 BusinessWorker 瞬间全部退出导致没有可用的 BusinessWorker 进程 Timer::add(0.05, array('Workerman\Worker', 'stopAll')); // 执行用户定义的 onWorkerReload 回调 if ($this->_onWorkerReload) { ...
php
protected function onWorkerReload($worker) { // 防止进程立刻退出 $worker->reloadable = false; // 延迟 0.05 秒退出,避免 BusinessWorker 瞬间全部退出导致没有可用的 BusinessWorker 进程 Timer::add(0.05, array('Workerman\Worker', 'stopAll')); // 执行用户定义的 onWorkerReload 回调 if ($this->_onWorkerReload) { ...
[ "protected", "function", "onWorkerReload", "(", "$", "worker", ")", "{", "// 防止进程立刻退出", "$", "worker", "->", "reloadable", "=", "false", ";", "// 延迟 0.05 秒退出,避免 BusinessWorker 瞬间全部退出导致没有可用的 BusinessWorker 进程", "Timer", "::", "add", "(", "0.05", ",", "array", "(", "'...
onWorkerReload 回调 @param Worker $worker
[ "onWorkerReload", "回调" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/BusinessWorker.php#L259-L269
walkor/GatewayWorker
src/BusinessWorker.php
BusinessWorker.onWorkerStop
protected function onWorkerStop() { if ($this->_onWorkerStop) { call_user_func($this->_onWorkerStop, $this); } if (is_callable($this->eventHandler . '::onWorkerStop')) { call_user_func($this->eventHandler . '::onWorkerStop', $this); } }
php
protected function onWorkerStop() { if ($this->_onWorkerStop) { call_user_func($this->_onWorkerStop, $this); } if (is_callable($this->eventHandler . '::onWorkerStop')) { call_user_func($this->eventHandler . '::onWorkerStop', $this); } }
[ "protected", "function", "onWorkerStop", "(", ")", "{", "if", "(", "$", "this", "->", "_onWorkerStop", ")", "{", "call_user_func", "(", "$", "this", "->", "_onWorkerStop", ",", "$", "this", ")", ";", "}", "if", "(", "is_callable", "(", "$", "this", "->...
当进程关闭时一些清理工作 @return void
[ "当进程关闭时一些清理工作" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/BusinessWorker.php#L276-L284
walkor/GatewayWorker
src/BusinessWorker.php
BusinessWorker.onRegisterConnectionMessage
public function onRegisterConnectionMessage($register_connection, $data) { $data = json_decode($data, true); if (!isset($data['event'])) { echo "Received bad data from Register\n"; return; } $event = $data['event']; switch ($event) { case '...
php
public function onRegisterConnectionMessage($register_connection, $data) { $data = json_decode($data, true); if (!isset($data['event'])) { echo "Received bad data from Register\n"; return; } $event = $data['event']; switch ($event) { case '...
[ "public", "function", "onRegisterConnectionMessage", "(", "$", "register_connection", ",", "$", "data", ")", "{", "$", "data", "=", "json_decode", "(", "$", "data", ",", "true", ")", ";", "if", "(", "!", "isset", "(", "$", "data", "[", "'event'", "]", ...
当注册中心发来消息时 @return void
[ "当注册中心发来消息时" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/BusinessWorker.php#L322-L346
walkor/GatewayWorker
src/BusinessWorker.php
BusinessWorker.onGatewayClose
public function onGatewayClose($connection) { $addr = $connection->remoteAddress; unset($this->gatewayConnections[$addr], $this->_connectingGatewayAddresses[$addr]); if (isset($this->_gatewayAddresses[$addr]) && !isset($this->_waitingConnectGatewayAddresses[$addr])) { Timer::add(...
php
public function onGatewayClose($connection) { $addr = $connection->remoteAddress; unset($this->gatewayConnections[$addr], $this->_connectingGatewayAddresses[$addr]); if (isset($this->_gatewayAddresses[$addr]) && !isset($this->_waitingConnectGatewayAddresses[$addr])) { Timer::add(...
[ "public", "function", "onGatewayClose", "(", "$", "connection", ")", "{", "$", "addr", "=", "$", "connection", "->", "remoteAddress", ";", "unset", "(", "$", "this", "->", "gatewayConnections", "[", "$", "addr", "]", ",", "$", "this", "->", "_connectingGat...
当与 Gateway 的连接断开时触发 @param TcpConnection $connection @return void
[ "当与", "Gateway", "的连接断开时触发" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/BusinessWorker.php#L443-L451
walkor/GatewayWorker
src/BusinessWorker.php
BusinessWorker.tryToConnectGateway
public function tryToConnectGateway($addr) { if (!isset($this->gatewayConnections[$addr]) && !isset($this->_connectingGatewayAddresses[$addr]) && isset($this->_gatewayAddresses[$addr])) { $gateway_connection = new AsyncTcpConnection("GatewayProtocol://$addr"); $gat...
php
public function tryToConnectGateway($addr) { if (!isset($this->gatewayConnections[$addr]) && !isset($this->_connectingGatewayAddresses[$addr]) && isset($this->_gatewayAddresses[$addr])) { $gateway_connection = new AsyncTcpConnection("GatewayProtocol://$addr"); $gat...
[ "public", "function", "tryToConnectGateway", "(", "$", "addr", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "gatewayConnections", "[", "$", "addr", "]", ")", "&&", "!", "isset", "(", "$", "this", "->", "_connectingGatewayAddresses", "[", "$...
尝试连接 Gateway 内部通讯地址 @param string $addr
[ "尝试连接", "Gateway", "内部通讯地址" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/BusinessWorker.php#L458-L482
walkor/GatewayWorker
src/BusinessWorker.php
BusinessWorker.checkGatewayConnections
public function checkGatewayConnections($addresses_list) { if (empty($addresses_list)) { return; } foreach ($addresses_list as $addr) { if (!isset($this->_waitingConnectGatewayAddresses[$addr])) { $this->tryToConnectGateway($addr); } ...
php
public function checkGatewayConnections($addresses_list) { if (empty($addresses_list)) { return; } foreach ($addresses_list as $addr) { if (!isset($this->_waitingConnectGatewayAddresses[$addr])) { $this->tryToConnectGateway($addr); } ...
[ "public", "function", "checkGatewayConnections", "(", "$", "addresses_list", ")", "{", "if", "(", "empty", "(", "$", "addresses_list", ")", ")", "{", "return", ";", "}", "foreach", "(", "$", "addresses_list", "as", "$", "addr", ")", "{", "if", "(", "!", ...
检查 gateway 的通信端口是否都已经连 如果有未连接的端口,则尝试连接 @param array $addresses_list
[ "检查", "gateway", "的通信端口是否都已经连", "如果有未连接的端口,则尝试连接" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/BusinessWorker.php#L490-L500
walkor/GatewayWorker
src/BusinessWorker.php
BusinessWorker.onConnectGateway
public function onConnectGateway($connection) { $this->gatewayConnections[$connection->remoteAddress] = $connection; unset($this->_connectingGatewayAddresses[$connection->remoteAddress], $this->_waitingConnectGatewayAddresses[$connection->remoteAddress]); }
php
public function onConnectGateway($connection) { $this->gatewayConnections[$connection->remoteAddress] = $connection; unset($this->_connectingGatewayAddresses[$connection->remoteAddress], $this->_waitingConnectGatewayAddresses[$connection->remoteAddress]); }
[ "public", "function", "onConnectGateway", "(", "$", "connection", ")", "{", "$", "this", "->", "gatewayConnections", "[", "$", "connection", "->", "remoteAddress", "]", "=", "$", "connection", ";", "unset", "(", "$", "this", "->", "_connectingGatewayAddresses", ...
当连接上 gateway 的通讯端口时触发 将连接 connection 对象保存起来 @param TcpConnection $connection @return void
[ "当连接上", "gateway", "的通讯端口时触发", "将连接", "connection", "对象保存起来" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/BusinessWorker.php#L509-L513
walkor/GatewayWorker
src/BusinessWorker.php
BusinessWorker.timeoutHandler
public function timeoutHandler($signal) { switch ($signal) { // 超时时钟 case SIGALRM: // 超时异常 $e = new \Exception("process_timeout", 506); $trace_str = $e->getTraceAsString(); // 去掉第一行timeoutHandler的调用栈 ...
php
public function timeoutHandler($signal) { switch ($signal) { // 超时时钟 case SIGALRM: // 超时异常 $e = new \Exception("process_timeout", 506); $trace_str = $e->getTraceAsString(); // 去掉第一行timeoutHandler的调用栈 ...
[ "public", "function", "timeoutHandler", "(", "$", "signal", ")", "{", "switch", "(", "$", "signal", ")", "{", "// 超时时钟", "case", "SIGALRM", ":", "// 超时异常", "$", "e", "=", "new", "\\", "Exception", "(", "\"process_timeout\"", ",", "506", ")", ";", "$", ...
业务超时回调 @param int $signal @throws \Exception
[ "业务超时回调" ]
train
https://github.com/walkor/GatewayWorker/blob/35dbd88f1fd31b801b54b73c8198fd1f9ba92d8f/src/BusinessWorker.php#L543-L559
m4tthumphrey/php-gitlab-api
lib/Gitlab/ResultPager.php
ResultPager.fetchAll
public function fetchAll(ApiInterface $api, $method, array $parameters = array()) { $result = call_user_func_array(array($api, $method), $parameters); while ($this->hasNext()) { $result = array_merge($result, $this->fetchNext()); } return $result; }
php
public function fetchAll(ApiInterface $api, $method, array $parameters = array()) { $result = call_user_func_array(array($api, $method), $parameters); while ($this->hasNext()) { $result = array_merge($result, $this->fetchNext()); } return $result; }
[ "public", "function", "fetchAll", "(", "ApiInterface", "$", "api", ",", "$", "method", ",", "array", "$", "parameters", "=", "array", "(", ")", ")", "{", "$", "result", "=", "call_user_func_array", "(", "array", "(", "$", "api", ",", "$", "method", ")"...
{@inheritdoc}
[ "{" ]
train
https://github.com/m4tthumphrey/php-gitlab-api/blob/d6e7539b79958a2228407247119546c6b1ada9d8/lib/Gitlab/ResultPager.php#L43-L51
m4tthumphrey/php-gitlab-api
lib/Gitlab/ResultPager.php
ResultPager.has
protected function has($key) { $lastResponse = $this->client->getResponseHistory()->getLastResponse(); if ($lastResponse == null) { return false; } $pagination = ResponseMediator::getPagination($lastResponse); if ($pagination == null) { return false; ...
php
protected function has($key) { $lastResponse = $this->client->getResponseHistory()->getLastResponse(); if ($lastResponse == null) { return false; } $pagination = ResponseMediator::getPagination($lastResponse); if ($pagination == null) { return false; ...
[ "protected", "function", "has", "(", "$", "key", ")", "{", "$", "lastResponse", "=", "$", "this", "->", "client", "->", "getResponseHistory", "(", ")", "->", "getLastResponse", "(", ")", ";", "if", "(", "$", "lastResponse", "==", "null", ")", "{", "ret...
{@inheritdoc}
[ "{" ]
train
https://github.com/m4tthumphrey/php-gitlab-api/blob/d6e7539b79958a2228407247119546c6b1ada9d8/lib/Gitlab/ResultPager.php#L104-L117
m4tthumphrey/php-gitlab-api
lib/Gitlab/ResultPager.php
ResultPager.get
protected function get($key) { if (!$this->has($key)) { return []; } $pagination = ResponseMediator::getPagination($this->client->getResponseHistory()->getLastResponse()); return ResponseMediator::getContent($this->client->getHttpClient()->get($pagination[$key])); }
php
protected function get($key) { if (!$this->has($key)) { return []; } $pagination = ResponseMediator::getPagination($this->client->getResponseHistory()->getLastResponse()); return ResponseMediator::getContent($this->client->getHttpClient()->get($pagination[$key])); }
[ "protected", "function", "get", "(", "$", "key", ")", "{", "if", "(", "!", "$", "this", "->", "has", "(", "$", "key", ")", ")", "{", "return", "[", "]", ";", "}", "$", "pagination", "=", "ResponseMediator", "::", "getPagination", "(", "$", "this", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/m4tthumphrey/php-gitlab-api/blob/d6e7539b79958a2228407247119546c6b1ada9d8/lib/Gitlab/ResultPager.php#L122-L131
m4tthumphrey/php-gitlab-api
lib/Gitlab/Api/Jobs.php
Jobs.all
public function all($project_id, array $parameters = []) { $resolver = $this->createOptionsResolver(); return $this->get("projects/".$this->encodePath($project_id)."/jobs", $resolver->resolve($parameters)); }
php
public function all($project_id, array $parameters = []) { $resolver = $this->createOptionsResolver(); return $this->get("projects/".$this->encodePath($project_id)."/jobs", $resolver->resolve($parameters)); }
[ "public", "function", "all", "(", "$", "project_id", ",", "array", "$", "parameters", "=", "[", "]", ")", "{", "$", "resolver", "=", "$", "this", "->", "createOptionsResolver", "(", ")", ";", "return", "$", "this", "->", "get", "(", "\"projects/\"", "....
@param int|string $project_id @param array $parameters ( @var string|string[] $scope The scope of jobs to show, one or array of: created, pending, running, failed, success, canceled, skipped, manual; showing all jobs if none provided. ) @return mixed
[ "@param", "int|string", "$project_id", "@param", "array", "$parameters", "(" ]
train
https://github.com/m4tthumphrey/php-gitlab-api/blob/d6e7539b79958a2228407247119546c6b1ada9d8/lib/Gitlab/Api/Jobs.php#L27-L32
m4tthumphrey/php-gitlab-api
lib/Gitlab/Api/Jobs.php
Jobs.pipelineJobs
public function pipelineJobs($project_id, $pipeline_id, array $parameters = []) { $resolver = $this->createOptionsResolver(); return $this->get( $this->getProjectPath($project_id, 'pipelines/').$this->encodePath($pipeline_id)."/jobs", $resolver->resolve($parameters) ...
php
public function pipelineJobs($project_id, $pipeline_id, array $parameters = []) { $resolver = $this->createOptionsResolver(); return $this->get( $this->getProjectPath($project_id, 'pipelines/').$this->encodePath($pipeline_id)."/jobs", $resolver->resolve($parameters) ...
[ "public", "function", "pipelineJobs", "(", "$", "project_id", ",", "$", "pipeline_id", ",", "array", "$", "parameters", "=", "[", "]", ")", "{", "$", "resolver", "=", "$", "this", "->", "createOptionsResolver", "(", ")", ";", "return", "$", "this", "->",...
@param int|string $project_id @param int $pipeline_id @param array $parameters ( @var string|string[] $scope The scope of jobs to show, one or array of: created, pending, running, failed, success, canceled, skipped, manual; showing all jobs if none provided. ) @return mixed
[ "@param", "int|string", "$project_id", "@param", "int", "$pipeline_id", "@param", "array", "$parameters", "(" ]
train
https://github.com/m4tthumphrey/php-gitlab-api/blob/d6e7539b79958a2228407247119546c6b1ada9d8/lib/Gitlab/Api/Jobs.php#L45-L53
m4tthumphrey/php-gitlab-api
lib/Gitlab/Api/Jobs.php
Jobs.createOptionsResolver
protected function createOptionsResolver() { $allowedScopeValues = [ self::SCOPE_CANCELED, self::SCOPE_CREATED, self::SCOPE_FAILED, self::SCOPE_MANUAL, self::SCOPE_PENDING, self::SCOPE_RUNNING, self::SCOPE_SKIPPED, ...
php
protected function createOptionsResolver() { $allowedScopeValues = [ self::SCOPE_CANCELED, self::SCOPE_CREATED, self::SCOPE_FAILED, self::SCOPE_MANUAL, self::SCOPE_PENDING, self::SCOPE_RUNNING, self::SCOPE_SKIPPED, ...
[ "protected", "function", "createOptionsResolver", "(", ")", "{", "$", "allowedScopeValues", "=", "[", "self", "::", "SCOPE_CANCELED", ",", "self", "::", "SCOPE_CREATED", ",", "self", "::", "SCOPE_FAILED", ",", "self", "::", "SCOPE_MANUAL", ",", "self", "::", "...
{@inheritdoc}
[ "{" ]
train
https://github.com/m4tthumphrey/php-gitlab-api/blob/d6e7539b79958a2228407247119546c6b1ada9d8/lib/Gitlab/Api/Jobs.php#L151-L177
m4tthumphrey/php-gitlab-api
lib/Gitlab/Client.php
Client.api
public function api($name) { switch ($name) { case 'deploy_keys': return $this->deployKeys(); case 'groups': return $this->groups(); case 'groupsMilestones': return $this->groupsMilestones(); ...
php
public function api($name) { switch ($name) { case 'deploy_keys': return $this->deployKeys(); case 'groups': return $this->groups(); case 'groupsMilestones': return $this->groupsMilestones(); ...
[ "public", "function", "api", "(", "$", "name", ")", "{", "switch", "(", "$", "name", ")", "{", "case", "'deploy_keys'", ":", "return", "$", "this", "->", "deployKeys", "(", ")", ";", "case", "'groups'", ":", "return", "$", "this", "->", "groups", "("...
@param string $name @return AbstractApi|mixed @throws InvalidArgumentException
[ "@param", "string", "$name" ]
train
https://github.com/m4tthumphrey/php-gitlab-api/blob/d6e7539b79958a2228407247119546c6b1ada9d8/lib/Gitlab/Client.php#L314-L396
m4tthumphrey/php-gitlab-api
lib/Gitlab/Client.php
Client.authenticate
public function authenticate($token, $authMethod = self::AUTH_URL_TOKEN, $sudo = null) { $this->httpClientBuilder->removePlugin(Authentication::class); $this->httpClientBuilder->addPlugin(new Authentication($authMethod, $token, $sudo)); return $this; }
php
public function authenticate($token, $authMethod = self::AUTH_URL_TOKEN, $sudo = null) { $this->httpClientBuilder->removePlugin(Authentication::class); $this->httpClientBuilder->addPlugin(new Authentication($authMethod, $token, $sudo)); return $this; }
[ "public", "function", "authenticate", "(", "$", "token", ",", "$", "authMethod", "=", "self", "::", "AUTH_URL_TOKEN", ",", "$", "sudo", "=", "null", ")", "{", "$", "this", "->", "httpClientBuilder", "->", "removePlugin", "(", "Authentication", "::", "class",...
Authenticate a user for all next requests @param string $token Gitlab private token @param string $authMethod One of the AUTH_* class constants @param string $sudo @return $this
[ "Authenticate", "a", "user", "for", "all", "next", "requests" ]
train
https://github.com/m4tthumphrey/php-gitlab-api/blob/d6e7539b79958a2228407247119546c6b1ada9d8/lib/Gitlab/Client.php#L406-L412
m4tthumphrey/php-gitlab-api
lib/Gitlab/Client.php
Client.setUrl
public function setUrl($url) { $this->httpClientBuilder->removePlugin(AddHostPlugin::class); $this->httpClientBuilder->addPlugin(new AddHostPlugin(UriFactoryDiscovery::find()->createUri($url))); return $this; }
php
public function setUrl($url) { $this->httpClientBuilder->removePlugin(AddHostPlugin::class); $this->httpClientBuilder->addPlugin(new AddHostPlugin(UriFactoryDiscovery::find()->createUri($url))); return $this; }
[ "public", "function", "setUrl", "(", "$", "url", ")", "{", "$", "this", "->", "httpClientBuilder", "->", "removePlugin", "(", "AddHostPlugin", "::", "class", ")", ";", "$", "this", "->", "httpClientBuilder", "->", "addPlugin", "(", "new", "AddHostPlugin", "(...
@param string $url @return $this
[ "@param", "string", "$url" ]
train
https://github.com/m4tthumphrey/php-gitlab-api/blob/d6e7539b79958a2228407247119546c6b1ada9d8/lib/Gitlab/Client.php#L419-L425
m4tthumphrey/php-gitlab-api
lib/Gitlab/Api/GroupsMilestones.php
GroupsMilestones.all
public function all($group_id, array $parameters = []) { $resolver = $this->createOptionsResolver(); $resolver->setDefined('iids') ->setAllowedTypes('iids', 'array') ->setAllowedValues('iids', function (array $value) { return count($value) == count(array_filte...
php
public function all($group_id, array $parameters = []) { $resolver = $this->createOptionsResolver(); $resolver->setDefined('iids') ->setAllowedTypes('iids', 'array') ->setAllowedValues('iids', function (array $value) { return count($value) == count(array_filte...
[ "public", "function", "all", "(", "$", "group_id", ",", "array", "$", "parameters", "=", "[", "]", ")", "{", "$", "resolver", "=", "$", "this", "->", "createOptionsResolver", "(", ")", ";", "$", "resolver", "->", "setDefined", "(", "'iids'", ")", "->",...
@param int $group_id @param array $parameters ( @var int[] $iids Return only the milestones having the given iids. @var string $state Return only active or closed milestones. @var string $search Return only milestones with a title or description matching the provided string. ) @return mixed
[ "@param", "int", "$group_id", "@param", "array", "$parameters", "(" ]
train
https://github.com/m4tthumphrey/php-gitlab-api/blob/d6e7539b79958a2228407247119546c6b1ada9d8/lib/Gitlab/Api/GroupsMilestones.php#L16-L31
m4tthumphrey/php-gitlab-api
lib/Gitlab/HttpClient/Plugin/ApiVersion.php
ApiVersion.handleRequest
public function handleRequest(RequestInterface $request, callable $next, callable $first) { $uri = $request->getUri(); if (substr($uri->getPath(), 0, 8) !== '/api/v4/') { $request = $request->withUri($uri->withPath('/api/v4/'.$uri->getPath())); } return $next($request);...
php
public function handleRequest(RequestInterface $request, callable $next, callable $first) { $uri = $request->getUri(); if (substr($uri->getPath(), 0, 8) !== '/api/v4/') { $request = $request->withUri($uri->withPath('/api/v4/'.$uri->getPath())); } return $next($request);...
[ "public", "function", "handleRequest", "(", "RequestInterface", "$", "request", ",", "callable", "$", "next", ",", "callable", "$", "first", ")", "{", "$", "uri", "=", "$", "request", "->", "getUri", "(", ")", ";", "if", "(", "substr", "(", "$", "uri",...
{@inheritdoc}
[ "{" ]
train
https://github.com/m4tthumphrey/php-gitlab-api/blob/d6e7539b79958a2228407247119546c6b1ada9d8/lib/Gitlab/HttpClient/Plugin/ApiVersion.php#L19-L28
m4tthumphrey/php-gitlab-api
lib/Gitlab/Api/AbstractApi.php
AbstractApi.getAsResponse
protected function getAsResponse($path, array $parameters = array(), $requestHeaders = array()) { $path = $this->preparePath($path, $parameters); return $this->client->getHttpClient()->get($path, $requestHeaders); }
php
protected function getAsResponse($path, array $parameters = array(), $requestHeaders = array()) { $path = $this->preparePath($path, $parameters); return $this->client->getHttpClient()->get($path, $requestHeaders); }
[ "protected", "function", "getAsResponse", "(", "$", "path", ",", "array", "$", "parameters", "=", "array", "(", ")", ",", "$", "requestHeaders", "=", "array", "(", ")", ")", "{", "$", "path", "=", "$", "this", "->", "preparePath", "(", "$", "path", "...
Performs a GET query and returns the response as a PSR-7 response object. @param string $path @param array $parameters @param array $requestHeaders @return ResponseInterface
[ "Performs", "a", "GET", "query", "and", "returns", "the", "response", "as", "a", "PSR", "-", "7", "response", "object", "." ]
train
https://github.com/m4tthumphrey/php-gitlab-api/blob/d6e7539b79958a2228407247119546c6b1ada9d8/lib/Gitlab/Api/AbstractApi.php#L62-L67
m4tthumphrey/php-gitlab-api
lib/Gitlab/Api/AbstractApi.php
AbstractApi.guessContentType
private function guessContentType($file) { if (!class_exists(\finfo::class, false)) { return 'application/octet-stream'; } $finfo = new \finfo(FILEINFO_MIME_TYPE); return $finfo->file($file); }
php
private function guessContentType($file) { if (!class_exists(\finfo::class, false)) { return 'application/octet-stream'; } $finfo = new \finfo(FILEINFO_MIME_TYPE); return $finfo->file($file); }
[ "private", "function", "guessContentType", "(", "$", "file", ")", "{", "if", "(", "!", "class_exists", "(", "\\", "finfo", "::", "class", ",", "false", ")", ")", "{", "return", "'application/octet-stream'", ";", "}", "$", "finfo", "=", "new", "\\", "finf...
@param $file @return string
[ "@param", "$file" ]
train
https://github.com/m4tthumphrey/php-gitlab-api/blob/d6e7539b79958a2228407247119546c6b1ada9d8/lib/Gitlab/Api/AbstractApi.php#L255-L263
m4tthumphrey/php-gitlab-api
lib/Gitlab/Api/Projects.php
Projects.all
public function all(array $parameters = []) { $resolver = $this->createOptionsResolver(); $booleanNormalizer = function (Options $resolver, $value) { return $value ? 'true' : 'false'; }; $resolver->setDefined('archived') ->setAllowedTypes('archived', 'bool') ...
php
public function all(array $parameters = []) { $resolver = $this->createOptionsResolver(); $booleanNormalizer = function (Options $resolver, $value) { return $value ? 'true' : 'false'; }; $resolver->setDefined('archived') ->setAllowedTypes('archived', 'bool') ...
[ "public", "function", "all", "(", "array", "$", "parameters", "=", "[", "]", ")", "{", "$", "resolver", "=", "$", "this", "->", "createOptionsResolver", "(", ")", ";", "$", "booleanNormalizer", "=", "function", "(", "Options", "$", "resolver", ",", "$", ...
@param array $parameters { @var bool $archived Limit by archived status. @var string $visibility Limit by visibility public, internal, or private. @var string $order_by Return projects ordered by id, name, path, created_at, updated_at, or last_activity_at fields...
[ "@param", "array", "$parameters", "{" ]
train
https://github.com/m4tthumphrey/php-gitlab-api/blob/d6e7539b79958a2228407247119546c6b1ada9d8/lib/Gitlab/Api/Projects.php#L35-L88
m4tthumphrey/php-gitlab-api
lib/Gitlab/Api/Projects.php
Projects.show
public function show($project_id, array $parameters = []) { $resolver = $this->createOptionsResolver(); $booleanNormalizer = function (Options $resolver, $value) { return $value ? true : false; }; $resolver->setDefined('statistics') ->setAllowedTypes('statisti...
php
public function show($project_id, array $parameters = []) { $resolver = $this->createOptionsResolver(); $booleanNormalizer = function (Options $resolver, $value) { return $value ? true : false; }; $resolver->setDefined('statistics') ->setAllowedTypes('statisti...
[ "public", "function", "show", "(", "$", "project_id", ",", "array", "$", "parameters", "=", "[", "]", ")", "{", "$", "resolver", "=", "$", "this", "->", "createOptionsResolver", "(", ")", ";", "$", "booleanNormalizer", "=", "function", "(", "Options", "$...
@param int|string $project_id @param array $parameters { @var bool $statistics Include project statistics. @var bool $with_custom_attributes Include project custom attributes. } @return mixed
[ "@param", "int|string", "$project_id", "@param", "array", "$parameters", "{" ]
train
https://github.com/m4tthumphrey/php-gitlab-api/blob/d6e7539b79958a2228407247119546c6b1ada9d8/lib/Gitlab/Api/Projects.php#L99-L114
m4tthumphrey/php-gitlab-api
lib/Gitlab/Api/Projects.php
Projects.pipelines
public function pipelines($project_id, array $parameters = []) { $resolver = $this->createOptionsResolver(); $booleanNormalizer = function (Options $resolver, $value) { return $value ? 'true' : 'false'; }; $resolver->setDefined('scope') ->setAllowedValues('sc...
php
public function pipelines($project_id, array $parameters = []) { $resolver = $this->createOptionsResolver(); $booleanNormalizer = function (Options $resolver, $value) { return $value ? 'true' : 'false'; }; $resolver->setDefined('scope') ->setAllowedValues('sc...
[ "public", "function", "pipelines", "(", "$", "project_id", ",", "array", "$", "parameters", "=", "[", "]", ")", "{", "$", "resolver", "=", "$", "this", "->", "createOptionsResolver", "(", ")", ";", "$", "booleanNormalizer", "=", "function", "(", "Options",...
@param int $project_id @param array $parameters ( @var string $scope The scope of pipelines, one of: running, pending, finished, branches, tags. @var string $status The status of pipelines, one of: running, pending, success, failed, canceled, skipped. @var string $ref The ref of pipelines. @var bo...
[ "@param", "int", "$project_id", "@param", "array", "$parameters", "(" ]
train
https://github.com/m4tthumphrey/php-gitlab-api/blob/d6e7539b79958a2228407247119546c6b1ada9d8/lib/Gitlab/Api/Projects.php#L193-L221