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 |
|---|---|---|---|---|---|---|---|---|---|---|
Innmind/neo4j-dbal | src/Query/Query.php | Query.merge | public function merge(string $variable = null, array $labels = []): self
{
$query = new self;
$query->clauses = $this->clauses->add(
new Clause\MergeClause(
Clause\Expression\Path::startWithNode($variable, $labels)
)
);
return $query;
} | php | public function merge(string $variable = null, array $labels = []): self
{
$query = new self;
$query->clauses = $this->clauses->add(
new Clause\MergeClause(
Clause\Expression\Path::startWithNode($variable, $labels)
)
);
return $query;
} | [
"public",
"function",
"merge",
"(",
"string",
"$",
"variable",
"=",
"null",
",",
"array",
"$",
"labels",
"=",
"[",
"]",
")",
":",
"self",
"{",
"$",
"query",
"=",
"new",
"self",
";",
"$",
"query",
"->",
"clauses",
"=",
"$",
"this",
"->",
"clauses",
... | Add a MERGE clause
@param string $variable
@param array $labels
@return self | [
"Add",
"a",
"MERGE",
"clause"
] | train | https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Query/Query.php#L667-L677 |
Innmind/neo4j-dbal | src/Query/Query.php | Query.limit | public function limit(string $cypher): self
{
$query = new self;
$query->clauses = $this->clauses->add(
new Clause\LimitClause($cypher)
);
return $query;
} | php | public function limit(string $cypher): self
{
$query = new self;
$query->clauses = $this->clauses->add(
new Clause\LimitClause($cypher)
);
return $query;
} | [
"public",
"function",
"limit",
"(",
"string",
"$",
"cypher",
")",
":",
"self",
"{",
"$",
"query",
"=",
"new",
"self",
";",
"$",
"query",
"->",
"clauses",
"=",
"$",
"this",
"->",
"clauses",
"->",
"add",
"(",
"new",
"Clause",
"\\",
"LimitClause",
"(",
... | Add a LIMIT clause
@see http://neo4j.com/docs/stable/query-limit.html#limit-return-first-from-expression
@param string $cypher
@return self | [
"Add",
"a",
"LIMIT",
"clause"
] | train | https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Query/Query.php#L687-L695 |
Innmind/neo4j-dbal | src/Query/Query.php | Query.foreach | public function foreach(string $cypher): self
{
$query = new self;
$query->clauses = $this->clauses->add(
new Clause\ForeachClause($cypher)
);
return $query;
} | php | public function foreach(string $cypher): self
{
$query = new self;
$query->clauses = $this->clauses->add(
new Clause\ForeachClause($cypher)
);
return $query;
} | [
"public",
"function",
"foreach",
"(",
"string",
"$",
"cypher",
")",
":",
"self",
"{",
"$",
"query",
"=",
"new",
"self",
";",
"$",
"query",
"->",
"clauses",
"=",
"$",
"this",
"->",
"clauses",
"->",
"add",
"(",
"new",
"Clause",
"\\",
"ForeachClause",
"... | Add a FOREACH clause
@param string $cypher
@return self | [
"Add",
"a",
"FOREACH",
"clause"
] | train | https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Query/Query.php#L704-L712 |
Innmind/neo4j-dbal | src/Query/Query.php | Query.delete | public function delete(string $variable, bool $detach = false): self
{
$query = new self;
$query->clauses = $this->clauses->add(
new Clause\DeleteClause($variable, $detach)
);
return $query;
} | php | public function delete(string $variable, bool $detach = false): self
{
$query = new self;
$query->clauses = $this->clauses->add(
new Clause\DeleteClause($variable, $detach)
);
return $query;
} | [
"public",
"function",
"delete",
"(",
"string",
"$",
"variable",
",",
"bool",
"$",
"detach",
"=",
"false",
")",
":",
"self",
"{",
"$",
"query",
"=",
"new",
"self",
";",
"$",
"query",
"->",
"clauses",
"=",
"$",
"this",
"->",
"clauses",
"->",
"add",
"... | Add a DELETE clause
@param string $variable
@param bool $detach
@return self | [
"Add",
"a",
"DELETE",
"clause"
] | train | https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Query/Query.php#L722-L730 |
Innmind/neo4j-dbal | src/Query/Query.php | Query.create | public function create(
string $variable,
array $labels = [],
bool $unique = false
): self {
$query = new self;
$query->clauses = $this->clauses->add(
new Clause\CreateClause(
Clause\Expression\Path::startWithNode($variable, $labels),
... | php | public function create(
string $variable,
array $labels = [],
bool $unique = false
): self {
$query = new self;
$query->clauses = $this->clauses->add(
new Clause\CreateClause(
Clause\Expression\Path::startWithNode($variable, $labels),
... | [
"public",
"function",
"create",
"(",
"string",
"$",
"variable",
",",
"array",
"$",
"labels",
"=",
"[",
"]",
",",
"bool",
"$",
"unique",
"=",
"false",
")",
":",
"self",
"{",
"$",
"query",
"=",
"new",
"self",
";",
"$",
"query",
"->",
"clauses",
"=",
... | Add a CREATE clause
@param string $variable
@param array $labels
@param bool $unique
@return self | [
"Add",
"a",
"CREATE",
"clause"
] | train | https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Query/Query.php#L741-L755 |
j-d/draggy | src/Draggy/Autocode/Templates/PHP/Entity1.php | Entity1.getTypeCheckLines | protected function getTypeCheckLines(PHPAttribute $attribute, array $allowedTypes)
{
$phpTypes = ['boolean', 'integer', 'float', 'string', 'array', 'object', 'null', 'NULL'];
$phpFunctions = [
'boolean' => 'is_bool',
'integer' => 'is_numeric',
'float' => 'is... | php | protected function getTypeCheckLines(PHPAttribute $attribute, array $allowedTypes)
{
$phpTypes = ['boolean', 'integer', 'float', 'string', 'array', 'object', 'null', 'NULL'];
$phpFunctions = [
'boolean' => 'is_bool',
'integer' => 'is_numeric',
'float' => 'is... | [
"protected",
"function",
"getTypeCheckLines",
"(",
"PHPAttribute",
"$",
"attribute",
",",
"array",
"$",
"allowedTypes",
")",
"{",
"$",
"phpTypes",
"=",
"[",
"'boolean'",
",",
"'integer'",
",",
"'float'",
",",
"'string'",
",",
"'array'",
",",
"'object'",
",",
... | Returns a condition to check for the $attribute type. It allows for one or more types, including objects.
@param PHPAttribute $attribute
@param string[] $allowedTypes An array with the basic types, or a sub array in case of objects. E.g. ['integer', ['object'=>'MyClass']]
@return string
@throws \RuntimeExcep... | [
"Returns",
"a",
"condition",
"to",
"check",
"for",
"the",
"$attribute",
"type",
".",
"It",
"allows",
"for",
"one",
"or",
"more",
"types",
"including",
"objects",
"."
] | train | https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Autocode/Templates/PHP/Entity1.php#L81-L129 |
j-d/draggy | src/Draggy/Autocode/Templates/PHP/Entity1.php | Entity1.getAttributeDocumentationLinesBasePart | public function getAttributeDocumentationLinesBasePart(PHPAttribute $attribute)
{
$lines = [];
if (null !== $attribute->getDescription()) {
$lines[] = $attribute->getDescription();
$lines[] = '';
}
$lines[] = '@var ' . $attribute->getPhpAnnotationType() . ' ... | php | public function getAttributeDocumentationLinesBasePart(PHPAttribute $attribute)
{
$lines = [];
if (null !== $attribute->getDescription()) {
$lines[] = $attribute->getDescription();
$lines[] = '';
}
$lines[] = '@var ' . $attribute->getPhpAnnotationType() . ' ... | [
"public",
"function",
"getAttributeDocumentationLinesBasePart",
"(",
"PHPAttribute",
"$",
"attribute",
")",
"{",
"$",
"lines",
"=",
"[",
"]",
";",
"if",
"(",
"null",
"!==",
"$",
"attribute",
"->",
"getDescription",
"(",
")",
")",
"{",
"$",
"lines",
"[",
"]... | <editor-fold desc="Attributes"> | [
"<editor",
"-",
"fold",
"desc",
"=",
"Attributes",
">"
] | train | https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Autocode/Templates/PHP/Entity1.php#L132-L144 |
j-d/draggy | src/Draggy/Autocode/Templates/PHP/Entity1.php | Entity1.getSetterInnerValidationCodeLines | public function getSetterInnerValidationCodeLines(PHPAttribute $attribute)
{
$lines = [];
if (null === $attribute->getPhpParameterType()) {
if ('boolean' === $attribute->getPhpType()) {
if (!$attribute->getNull()) {
$lines = array_merge($lines, $this-... | php | public function getSetterInnerValidationCodeLines(PHPAttribute $attribute)
{
$lines = [];
if (null === $attribute->getPhpParameterType()) {
if ('boolean' === $attribute->getPhpType()) {
if (!$attribute->getNull()) {
$lines = array_merge($lines, $this-... | [
"public",
"function",
"getSetterInnerValidationCodeLines",
"(",
"PHPAttribute",
"$",
"attribute",
")",
"{",
"$",
"lines",
"=",
"[",
"]",
";",
"if",
"(",
"null",
"===",
"$",
"attribute",
"->",
"getPhpParameterType",
"(",
")",
")",
"{",
"if",
"(",
"'boolean'",... | <editor-fold desc="Setters"> | [
"<editor",
"-",
"fold",
"desc",
"=",
"Setters",
">"
] | train | https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Autocode/Templates/PHP/Entity1.php#L202-L271 |
j-d/draggy | src/Draggy/Autocode/Templates/PHP/Entity1.php | Entity1.getGetterCodeDocumentationLines | public function getGetterCodeDocumentationLines(PHPAttribute $attribute)
{
$lines = [];
$lines[] = 'Get ' . $attribute->getLowerFullName();
$lines[] = '';
$lines[] = '@return ' . $attribute->getPhpAnnotationTypeBase();
return $lines;
} | php | public function getGetterCodeDocumentationLines(PHPAttribute $attribute)
{
$lines = [];
$lines[] = 'Get ' . $attribute->getLowerFullName();
$lines[] = '';
$lines[] = '@return ' . $attribute->getPhpAnnotationTypeBase();
return $lines;
} | [
"public",
"function",
"getGetterCodeDocumentationLines",
"(",
"PHPAttribute",
"$",
"attribute",
")",
"{",
"$",
"lines",
"=",
"[",
"]",
";",
"$",
"lines",
"[",
"]",
"=",
"'Get '",
".",
"$",
"attribute",
"->",
"getLowerFullName",
"(",
")",
";",
"$",
"lines",... | <editor-fold desc="Getters"> | [
"<editor",
"-",
"fold",
"desc",
"=",
"Getters",
">"
] | train | https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Autocode/Templates/PHP/Entity1.php#L423-L432 |
j-d/draggy | src/Draggy/Autocode/Templates/PHP/Entity1.php | Entity1.getSingleAdderCodeDocumentationParameterLines | public function getSingleAdderCodeDocumentationParameterLines(PHPAttribute $attribute)
{
$lines = [];
$lines[] = '@param ' . $attribute->getPhpSingleTypeBase() . ' $' . $attribute->getSingleName();
$lines[] = '@param bool $_allowRepeatedValues';
return $lines;
} | php | public function getSingleAdderCodeDocumentationParameterLines(PHPAttribute $attribute)
{
$lines = [];
$lines[] = '@param ' . $attribute->getPhpSingleTypeBase() . ' $' . $attribute->getSingleName();
$lines[] = '@param bool $_allowRepeatedValues';
return $lines;
} | [
"public",
"function",
"getSingleAdderCodeDocumentationParameterLines",
"(",
"PHPAttribute",
"$",
"attribute",
")",
"{",
"$",
"lines",
"=",
"[",
"]",
";",
"$",
"lines",
"[",
"]",
"=",
"'@param '",
".",
"$",
"attribute",
"->",
"getPhpSingleTypeBase",
"(",
")",
"... | <editor-fold desc="Adders"> | [
"<editor",
"-",
"fold",
"desc",
"=",
"Adders",
">"
] | train | https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Autocode/Templates/PHP/Entity1.php#L453-L461 |
j-d/draggy | src/Draggy/Autocode/Templates/PHP/Entity1.php | Entity1.getSingleContainsCodeDocumentationLines | public function getSingleContainsCodeDocumentationLines(PHPAttribute $attribute)
{
$lines = [];
$lines[] = 'Contains ' . $attribute->getSingleName();
$lines[] = '';
$lines[] = '@param ' . $attribute->getPhpSingleTypeBase() /*. ($attribute->getEntity()->getProject()->getBase() ? 'Bas... | php | public function getSingleContainsCodeDocumentationLines(PHPAttribute $attribute)
{
$lines = [];
$lines[] = 'Contains ' . $attribute->getSingleName();
$lines[] = '';
$lines[] = '@param ' . $attribute->getPhpSingleTypeBase() /*. ($attribute->getEntity()->getProject()->getBase() ? 'Bas... | [
"public",
"function",
"getSingleContainsCodeDocumentationLines",
"(",
"PHPAttribute",
"$",
"attribute",
")",
"{",
"$",
"lines",
"=",
"[",
"]",
";",
"$",
"lines",
"[",
"]",
"=",
"'Contains '",
".",
"$",
"attribute",
"->",
"getSingleName",
"(",
")",
";",
"$",
... | <editor-fold desc="Contains"> | [
"<editor",
"-",
"fold",
"desc",
"=",
"Contains",
">"
] | train | https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Autocode/Templates/PHP/Entity1.php#L604-L615 |
j-d/draggy | src/Draggy/Autocode/Templates/PHP/Entity1.php | Entity1.getSingleRemoverCodeDocumentationParameterLines | public function getSingleRemoverCodeDocumentationParameterLines(PHPAttribute $attribute)
{
$lines = [];
$lines[] = '@param ' . $attribute->getPhpSingleTypeBase() /*. ($attribute->getEntity()->getProject()->getBase() ? 'Base' : '')*/ . ' $' . $attribute->getSingleName();
return $lines;
... | php | public function getSingleRemoverCodeDocumentationParameterLines(PHPAttribute $attribute)
{
$lines = [];
$lines[] = '@param ' . $attribute->getPhpSingleTypeBase() /*. ($attribute->getEntity()->getProject()->getBase() ? 'Base' : '')*/ . ' $' . $attribute->getSingleName();
return $lines;
... | [
"public",
"function",
"getSingleRemoverCodeDocumentationParameterLines",
"(",
"PHPAttribute",
"$",
"attribute",
")",
"{",
"$",
"lines",
"=",
"[",
"]",
";",
"$",
"lines",
"[",
"]",
"=",
"'@param '",
".",
"$",
"attribute",
"->",
"getPhpSingleTypeBase",
"(",
")",
... | <editor-fold desc="Removers"> | [
"<editor",
"-",
"fold",
"desc",
"=",
"Removers",
">"
] | train | https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Autocode/Templates/PHP/Entity1.php#L678-L685 |
j-d/draggy | src/Draggy/Autocode/Templates/PHP/Entity1.php | Entity1.getSetterGetterLines | public function getSetterGetterLines(PHPAttribute $attribute)
{
$lines = [];
if ($attribute->getSetter()) {
$lines = array_merge($lines, $this->getSetterCodeLines($attribute));
}
if ('Collection' === $attribute->getPhpParameterType() || 'array' === $attribute->getType()... | php | public function getSetterGetterLines(PHPAttribute $attribute)
{
$lines = [];
if ($attribute->getSetter()) {
$lines = array_merge($lines, $this->getSetterCodeLines($attribute));
}
if ('Collection' === $attribute->getPhpParameterType() || 'array' === $attribute->getType()... | [
"public",
"function",
"getSetterGetterLines",
"(",
"PHPAttribute",
"$",
"attribute",
")",
"{",
"$",
"lines",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"attribute",
"->",
"getSetter",
"(",
")",
")",
"{",
"$",
"lines",
"=",
"array_merge",
"(",
"$",
"lines",
",... | </editor-fold> | [
"<",
"/",
"editor",
"-",
"fold",
">"
] | train | https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Autocode/Templates/PHP/Entity1.php#L825-L870 |
nabab/bbn | src/bbn/file.php | file.get_size | public function get_size()
{
if ( $this->file && $this->size === 0 ){
$this->size = filesize($this->file);
}
return $this->size;
} | php | public function get_size()
{
if ( $this->file && $this->size === 0 ){
$this->size = filesize($this->file);
}
return $this->size;
} | [
"public",
"function",
"get_size",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"file",
"&&",
"$",
"this",
"->",
"size",
"===",
"0",
")",
"{",
"$",
"this",
"->",
"size",
"=",
"filesize",
"(",
"$",
"this",
"->",
"file",
")",
";",
"}",
"return",
"... | Return the filesize in byte.
```php
$file = new bbn\file('C:/Test/file.txt');
bbn\x::dump($file->get_size());
// (int) 314
```
@return int | [
"Return",
"the",
"filesize",
"in",
"byte",
"."
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/file.php#L126-L132 |
nabab/bbn | src/bbn/file.php | file.get_extension | public function get_extension()
{
if ( $this->name ){
if ( !isset($this->ext) ){
if ( strpos($this->name, '.') !== false ){
$p = str::file_ext($this->name, 1);
$this->ext = $p[1];
$this->title = $p[0];
}
else{
$this->ext = '';
$this->... | php | public function get_extension()
{
if ( $this->name ){
if ( !isset($this->ext) ){
if ( strpos($this->name, '.') !== false ){
$p = str::file_ext($this->name, 1);
$this->ext = $p[1];
$this->title = $p[0];
}
else{
$this->ext = '';
$this->... | [
"public",
"function",
"get_extension",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"name",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"ext",
")",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"this",
"->",
"name",
",",
"'.'",
")",
... | Return the extension of the file.
```php
$file = new file('C:/Test/file.txt');
bbn\x::dump($file->get_extension());
//(string) 'txt'
```
@return string|false | [
"Return",
"the",
"extension",
"of",
"the",
"file",
"."
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/file.php#L163-L180 |
nabab/bbn | src/bbn/file.php | file.make | protected function make()
{
if ( !$this->file && strpos($this->path,'http://') === 0 ){
$d = getcwd();
chdir(__DIR__);
chdir('../tmp');
$f = tempnam('.','image');
try{
$c = file_get_contents($this->path.$this->name);
if ( file_put_contents($f, $c) ){
if ( su... | php | protected function make()
{
if ( !$this->file && strpos($this->path,'http://') === 0 ){
$d = getcwd();
chdir(__DIR__);
chdir('../tmp');
$f = tempnam('.','image');
try{
$c = file_get_contents($this->path.$this->name);
if ( file_put_contents($f, $c) ){
if ( su... | [
"protected",
"function",
"make",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"file",
"&&",
"strpos",
"(",
"$",
"this",
"->",
"path",
",",
"'http://'",
")",
"===",
"0",
")",
"{",
"$",
"d",
"=",
"getcwd",
"(",
")",
";",
"chdir",
"(",
"__DIR... | Creates a temporary file in tmp directory.
@todo of adjusting
@return file | [
"Creates",
"a",
"temporary",
"file",
"in",
"tmp",
"directory",
"."
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/file.php#L188-L214 |
nabab/bbn | src/bbn/file.php | file.download | public function download()
{
if ( $this->file ){
if ( !$this->size ){
$this->get_size();
}
if ( $this->size && ($handle = fopen($this->file, 'r')) ){
header('Content-type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.$this->name.'"');
... | php | public function download()
{
if ( $this->file ){
if ( !$this->size ){
$this->get_size();
}
if ( $this->size && ($handle = fopen($this->file, 'r')) ){
header('Content-type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.$this->name.'"');
... | [
"public",
"function",
"download",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"file",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"size",
")",
"{",
"$",
"this",
"->",
"get_size",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"size",
"&&... | Downloads the file. At the end of the script the user will be invited to choose the file's destination. If the file doesn't exist return an object with parameter file = null.
```php
$f = new \bbn\file('C:/Test/file.png');
$f->download();
```
@return file | [
"Downloads",
"the",
"file",
".",
"At",
"the",
"end",
"of",
"the",
"script",
"the",
"user",
"will",
"be",
"invited",
"to",
"choose",
"the",
"file",
"s",
"destination",
".",
"If",
"the",
"file",
"doesn",
"t",
"exist",
"return",
"an",
"object",
"with",
"p... | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/file.php#L226-L245 |
nabab/bbn | src/bbn/file.php | file.delete | public function delete()
{
if ( $this->file ){
unlink($this->file);
}
$this->file = false;
return $this;
} | php | public function delete()
{
if ( $this->file ){
unlink($this->file);
}
$this->file = false;
return $this;
} | [
"public",
"function",
"delete",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"file",
")",
"{",
"unlink",
"(",
"$",
"this",
"->",
"file",
")",
";",
"}",
"$",
"this",
"->",
"file",
"=",
"false",
";",
"return",
"$",
"this",
";",
"}"
] | Deletes the file.
```php
bbn\x::hdump( is_file('C:/Test/file.txt') );
// (bool) true
$file = new file('C:/Test/file.txt');
$file->delete();
bbn\x::hdump( is_file('C:/Test/file.txt') );
// (bool) false
```
@return file | [
"Deletes",
"the",
"file",
"."
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/file.php#L280-L287 |
nabab/bbn | src/bbn/file.php | file.save | public function save($dest='./')
{
$new_name = false;
if ( substr($dest,-1) === '/' ){
if ( is_dir($dest) ){
$new_name = 0;
}
}
else if ( is_dir($dest) ){
$dest .= '/';
$new_name = 0;
}
else if ( is_dir(substr($dest,0,strrpos($dest,'/'))) ){
$new_name = 1;... | php | public function save($dest='./')
{
$new_name = false;
if ( substr($dest,-1) === '/' ){
if ( is_dir($dest) ){
$new_name = 0;
}
}
else if ( is_dir($dest) ){
$dest .= '/';
$new_name = 0;
}
else if ( is_dir(substr($dest,0,strrpos($dest,'/'))) ){
$new_name = 1;... | [
"public",
"function",
"save",
"(",
"$",
"dest",
"=",
"'./'",
")",
"{",
"$",
"new_name",
"=",
"false",
";",
"if",
"(",
"substr",
"(",
"$",
"dest",
",",
"-",
"1",
")",
"===",
"'/'",
")",
"{",
"if",
"(",
"is_dir",
"(",
"$",
"dest",
")",
")",
"{"... | That feature saves the file as a parameter, and accepts a string that contains the path where to save.
```php
$file->save('/home/user/desktop/');
```
@param string $dest
@return file | [
"That",
"feature",
"saves",
"the",
"file",
"as",
"a",
"parameter",
"and",
"accepts",
"a",
"string",
"that",
"contains",
"the",
"path",
"where",
"to",
"save",
"."
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/file.php#L299-L328 |
PHPPowertools/HTML5 | src/PowerTools/HTML5/Inputstream/String.php | HTML5_Inputstream_String.currentLine | public function currentLine() {
if (empty($this->EOF) || $this->char == 0) {
return 1;
}
// Add one to $this->char because we want the number for the next
// byte to be processed.
return substr_count($this->data, "\n", 0, min($this->char, $this->EOF)) + 1;
} | php | public function currentLine() {
if (empty($this->EOF) || $this->char == 0) {
return 1;
}
// Add one to $this->char because we want the number for the next
// byte to be processed.
return substr_count($this->data, "\n", 0, min($this->char, $this->EOF)) + 1;
} | [
"public",
"function",
"currentLine",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"EOF",
")",
"||",
"$",
"this",
"->",
"char",
"==",
"0",
")",
"{",
"return",
"1",
";",
"}",
"// Add one to $this->char because we want the number for the next",
"/... | Returns the current line that the tokenizer is at. | [
"Returns",
"the",
"current",
"line",
"that",
"the",
"tokenizer",
"is",
"at",
"."
] | train | https://github.com/PHPPowertools/HTML5/blob/4ea8caf5b2618a82ca5061dcbb7421b31065c1c7/src/PowerTools/HTML5/Inputstream/String.php#L195-L202 |
PHPPowertools/HTML5 | src/PowerTools/HTML5/Inputstream/String.php | HTML5_Inputstream_String.columnOffset | public function columnOffset() {
// Short circuit for the first char.
if ($this->char == 0) {
return 0;
}
// strrpos is weird, and the offset needs to be negative for what we
// want (i.e., the last \n before $this->char). This needs to not have
// one (to mak... | php | public function columnOffset() {
// Short circuit for the first char.
if ($this->char == 0) {
return 0;
}
// strrpos is weird, and the offset needs to be negative for what we
// want (i.e., the last \n before $this->char). This needs to not have
// one (to mak... | [
"public",
"function",
"columnOffset",
"(",
")",
"{",
"// Short circuit for the first char.",
"if",
"(",
"$",
"this",
"->",
"char",
"==",
"0",
")",
"{",
"return",
"0",
";",
"}",
"// strrpos is weird, and the offset needs to be negative for what we",
"// want (i.e., the las... | Returns the current column of the current line that the tokenizer is at.
Newlines are column 0. The first char after a newline is column 1.
@return int The column number. | [
"Returns",
"the",
"current",
"column",
"of",
"the",
"current",
"line",
"that",
"the",
"tokenizer",
"is",
"at",
"."
] | train | https://github.com/PHPPowertools/HTML5/blob/4ea8caf5b2618a82ca5061dcbb7421b31065c1c7/src/PowerTools/HTML5/Inputstream/String.php#L220-L243 |
PHPPowertools/HTML5 | src/PowerTools/HTML5/Inputstream/String.php | HTML5_Inputstream_String.unconsume | public function unconsume($howMany = 1) {
if (($this->char - $howMany) >= 0) {
$this->char = $this->char - $howMany;
}
} | php | public function unconsume($howMany = 1) {
if (($this->char - $howMany) >= 0) {
$this->char = $this->char - $howMany;
}
} | [
"public",
"function",
"unconsume",
"(",
"$",
"howMany",
"=",
"1",
")",
"{",
"if",
"(",
"(",
"$",
"this",
"->",
"char",
"-",
"$",
"howMany",
")",
">=",
"0",
")",
"{",
"$",
"this",
"->",
"char",
"=",
"$",
"this",
"->",
"char",
"-",
"$",
"howMany"... | Unconsume characters.
@param int $howMany
The number of characters to unconsume. | [
"Unconsume",
"characters",
"."
] | train | https://github.com/PHPPowertools/HTML5/blob/4ea8caf5b2618a82ca5061dcbb7421b31065c1c7/src/PowerTools/HTML5/Inputstream/String.php#L380-L384 |
PHPPowertools/HTML5 | src/PowerTools/HTML5/Inputstream/String.php | HTML5_Inputstream_String.peek | public function peek() {
if (($this->char + 1) <= $this->EOF) {
return $this->data[$this->char + 1];
}
return false;
} | php | public function peek() {
if (($this->char + 1) <= $this->EOF) {
return $this->data[$this->char + 1];
}
return false;
} | [
"public",
"function",
"peek",
"(",
")",
"{",
"if",
"(",
"(",
"$",
"this",
"->",
"char",
"+",
"1",
")",
"<=",
"$",
"this",
"->",
"EOF",
")",
"{",
"return",
"$",
"this",
"->",
"data",
"[",
"$",
"this",
"->",
"char",
"+",
"1",
"]",
";",
"}",
"... | Look ahead without moving cursor. | [
"Look",
"ahead",
"without",
"moving",
"cursor",
"."
] | train | https://github.com/PHPPowertools/HTML5/blob/4ea8caf5b2618a82ca5061dcbb7421b31065c1c7/src/PowerTools/HTML5/Inputstream/String.php#L389-L395 |
spiral-modules/listing | source/Listing/InputState.php | InputState.isActive | public function isActive()
{
if (empty($this->source)) {
return false;
}
$input = $this->input->getValue($this->source, "{$this->namespace}");
return !empty($input);
} | php | public function isActive()
{
if (empty($this->source)) {
return false;
}
$input = $this->input->getValue($this->source, "{$this->namespace}");
return !empty($input);
} | [
"public",
"function",
"isActive",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"source",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"input",
"=",
"$",
"this",
"->",
"input",
"->",
"getValue",
"(",
"$",
"this",
"->",
"source",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/spiral-modules/listing/blob/89abe8939ce91cbf61b51b99e93ce1e57c8af83c/source/Listing/InputState.php#L74-L83 |
spiral-modules/listing | source/Listing/InputState.php | InputState.activeFilters | public function activeFilters()
{
$filters = $this->input->getValue($this->source, "{$this->namespace}." . self::FILTERS);
if (empty($filters) || !is_array($filters)) {
$filters = [];
}
return array_values($filters);
} | php | public function activeFilters()
{
$filters = $this->input->getValue($this->source, "{$this->namespace}." . self::FILTERS);
if (empty($filters) || !is_array($filters)) {
$filters = [];
}
return array_values($filters);
} | [
"public",
"function",
"activeFilters",
"(",
")",
"{",
"$",
"filters",
"=",
"$",
"this",
"->",
"input",
"->",
"getValue",
"(",
"$",
"this",
"->",
"source",
",",
"\"{$this->namespace}.\"",
".",
"self",
"::",
"FILTERS",
")",
";",
"if",
"(",
"empty",
"(",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/spiral-modules/listing/blob/89abe8939ce91cbf61b51b99e93ce1e57c8af83c/source/Listing/InputState.php#L107-L116 |
spiral-modules/listing | source/Listing/InputState.php | InputState.getValue | public function getValue($filter, $default = null)
{
$value = $this->input->getValue(
$this->source,
"{$this->namespace}." . self::FILTER_VALUES . '.' . $filter
);
if (null == $value) {
return $default;
}
return $value;
} | php | public function getValue($filter, $default = null)
{
$value = $this->input->getValue(
$this->source,
"{$this->namespace}." . self::FILTER_VALUES . '.' . $filter
);
if (null == $value) {
return $default;
}
return $value;
} | [
"public",
"function",
"getValue",
"(",
"$",
"filter",
",",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"input",
"->",
"getValue",
"(",
"$",
"this",
"->",
"source",
",",
"\"{$this->namespace}.\"",
".",
"self",
"::",
"FIL... | {@inheritdoc} | [
"{"
] | train | https://github.com/spiral-modules/listing/blob/89abe8939ce91cbf61b51b99e93ce1e57c8af83c/source/Listing/InputState.php#L121-L133 |
spiral-modules/listing | source/Listing/InputState.php | InputState.activeSorter | public function activeSorter()
{
$sorter = $this->input->getValue($this->source, "{$this->namespace}." . self::SORTER);
if (empty($sorter)) {
$sorter = 'id';
}
return $sorter;
} | php | public function activeSorter()
{
$sorter = $this->input->getValue($this->source, "{$this->namespace}." . self::SORTER);
if (empty($sorter)) {
$sorter = 'id';
}
return $sorter;
} | [
"public",
"function",
"activeSorter",
"(",
")",
"{",
"$",
"sorter",
"=",
"$",
"this",
"->",
"input",
"->",
"getValue",
"(",
"$",
"this",
"->",
"source",
",",
"\"{$this->namespace}.\"",
".",
"self",
"::",
"SORTER",
")",
";",
"if",
"(",
"empty",
"(",
"$"... | {@inheritdoc} | [
"{"
] | train | https://github.com/spiral-modules/listing/blob/89abe8939ce91cbf61b51b99e93ce1e57c8af83c/source/Listing/InputState.php#L138-L146 |
spiral-modules/listing | source/Listing/InputState.php | InputState.sortDirection | public function sortDirection()
{
$direction = $this->input->getValue($this->source, "{$this->namespace}." . self::DIRECTION);
if (strtolower($direction) == 'desc' || $direction == -1) {
return DirectionalSorter::DESC;
}
return DirectionalSorter::ASC;
} | php | public function sortDirection()
{
$direction = $this->input->getValue($this->source, "{$this->namespace}." . self::DIRECTION);
if (strtolower($direction) == 'desc' || $direction == -1) {
return DirectionalSorter::DESC;
}
return DirectionalSorter::ASC;
} | [
"public",
"function",
"sortDirection",
"(",
")",
"{",
"$",
"direction",
"=",
"$",
"this",
"->",
"input",
"->",
"getValue",
"(",
"$",
"this",
"->",
"source",
",",
"\"{$this->namespace}.\"",
".",
"self",
"::",
"DIRECTION",
")",
";",
"if",
"(",
"strtolower",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/spiral-modules/listing/blob/89abe8939ce91cbf61b51b99e93ce1e57c8af83c/source/Listing/InputState.php#L151-L160 |
surebert/surebert-framework | src/sb/ICalendar/Event.php | Event.send | public function send()
{
$subject = 'EVENT';
if ($this->method == 'CANCEL') {
$subject = 'CANCELED ' . $subject;
if (empty($this->uid)) {
throw(new \Exception('Must set uid to cancel an event.'));
}
}
if (!empty($this->summary)) {... | php | public function send()
{
$subject = 'EVENT';
if ($this->method == 'CANCEL') {
$subject = 'CANCELED ' . $subject;
if (empty($this->uid)) {
throw(new \Exception('Must set uid to cancel an event.'));
}
}
if (!empty($this->summary)) {... | [
"public",
"function",
"send",
"(",
")",
"{",
"$",
"subject",
"=",
"'EVENT'",
";",
"if",
"(",
"$",
"this",
"->",
"method",
"==",
"'CANCEL'",
")",
"{",
"$",
"subject",
"=",
"'CANCELED '",
".",
"$",
"subject",
";",
"if",
"(",
"empty",
"(",
"$",
"this"... | Send via email the subject is the first 20 chars of the summary,
the message is the summary. The email is sent to the organizer's email,
The attendees all cc'd
@return boolean | [
"Send",
"via",
"email",
"the",
"subject",
"is",
"the",
"first",
"20",
"chars",
"of",
"the",
"summary",
"the",
"message",
"is",
"the",
"summary",
".",
"The",
"email",
"is",
"sent",
"to",
"the",
"organizer",
"s",
"email",
"The",
"attendees",
"all",
"cc",
... | train | https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/ICalendar/Event.php#L174-L200 |
inhere/php-librarys | src/Helpers/ArrayHelper.php | ArrayHelper.valueTrim | public static function valueTrim(array $data)
{
if (is_scalar($data)) {
return trim($data);
}
array_walk_recursive($data, function (&$value) {
$value = trim($value);
});
return $data;
} | php | public static function valueTrim(array $data)
{
if (is_scalar($data)) {
return trim($data);
}
array_walk_recursive($data, function (&$value) {
$value = trim($value);
});
return $data;
} | [
"public",
"static",
"function",
"valueTrim",
"(",
"array",
"$",
"data",
")",
"{",
"if",
"(",
"is_scalar",
"(",
"$",
"data",
")",
")",
"{",
"return",
"trim",
"(",
"$",
"data",
")",
";",
"}",
"array_walk_recursive",
"(",
"$",
"data",
",",
"function",
"... | 清理数组值的空白
@param array $data
@return array|string | [
"清理数组值的空白"
] | train | https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Helpers/ArrayHelper.php#L184-L195 |
inhere/php-librarys | src/Helpers/ArrayHelper.php | ArrayHelper.changeValueCase | public static function changeValueCase($arr, $toUpper = 1): array
{
$function = $toUpper ? 'strtoupper' : 'strtolower';
$newArr = array(); //格式化后的数组
foreach ($arr as $k => $v) {
if (\is_array($v)) {
$newArr[$k] = self::changeValueCase($v, $toUpper);
}... | php | public static function changeValueCase($arr, $toUpper = 1): array
{
$function = $toUpper ? 'strtoupper' : 'strtolower';
$newArr = array(); //格式化后的数组
foreach ($arr as $k => $v) {
if (\is_array($v)) {
$newArr[$k] = self::changeValueCase($v, $toUpper);
}... | [
"public",
"static",
"function",
"changeValueCase",
"(",
"$",
"arr",
",",
"$",
"toUpper",
"=",
"1",
")",
":",
"array",
"{",
"$",
"function",
"=",
"$",
"toUpper",
"?",
"'strtoupper'",
":",
"'strtolower'",
";",
"$",
"newArr",
"=",
"array",
"(",
")",
";",
... | 将数组中的值全部转为大写或小写
@param array $arr
@param int $toUpper 1 值大写 0 值小写
@return array | [
"将数组中的值全部转为大写或小写"
] | train | https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Helpers/ArrayHelper.php#L232-L247 |
inhere/php-librarys | src/Helpers/ArrayHelper.php | ArrayHelper.getByPath | public static function getByPath($data, $path, $default = null, $separator = '.')
{
if (isset($data[$path])) {
return $data[$path];
}
$nodes = Str::toArray($path, $separator);
if (!$nodes) {
return $default;
}
$dataTmp = $data;
fore... | php | public static function getByPath($data, $path, $default = null, $separator = '.')
{
if (isset($data[$path])) {
return $data[$path];
}
$nodes = Str::toArray($path, $separator);
if (!$nodes) {
return $default;
}
$dataTmp = $data;
fore... | [
"public",
"static",
"function",
"getByPath",
"(",
"$",
"data",
",",
"$",
"path",
",",
"$",
"default",
"=",
"null",
",",
"$",
"separator",
"=",
"'.'",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"$",
"path",
"]",
")",
")",
"{",
"return",
... | Get data from array or object by path.
Example: `DataCollector::getByPath($array, 'foo.bar.yoo')` equals to $array['foo']['bar']['yoo'].
@param array|\ArrayAccess $data An array or object to get value.
@param mixed $path The key path.
@param mixed $default
@param string $separator Separator of paths.
@return mixed Foun... | [
"Get",
"data",
"from",
"array",
"or",
"object",
"by",
"path",
".",
"Example",
":",
"DataCollector",
"::",
"getByPath",
"(",
"$array",
"foo",
".",
"bar",
".",
"yoo",
")",
"equals",
"to",
"$array",
"[",
"foo",
"]",
"[",
"bar",
"]",
"[",
"yoo",
"]",
"... | train | https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Helpers/ArrayHelper.php#L390-L418 |
inhere/php-librarys | src/Helpers/ArrayHelper.php | ArrayHelper.setByPath | public static function setByPath(&$data, $path, $value, $separator = '.')
{
if (false === strpos($path, $separator)) {
$data[$path] = $value;
return true;
}
if (!$nodes = Str::toArray($path, $separator)) {
return false;
}
$dataTmp = &$da... | php | public static function setByPath(&$data, $path, $value, $separator = '.')
{
if (false === strpos($path, $separator)) {
$data[$path] = $value;
return true;
}
if (!$nodes = Str::toArray($path, $separator)) {
return false;
}
$dataTmp = &$da... | [
"public",
"static",
"function",
"setByPath",
"(",
"&",
"$",
"data",
",",
"$",
"path",
",",
"$",
"value",
",",
"$",
"separator",
"=",
"'.'",
")",
"{",
"if",
"(",
"false",
"===",
"strpos",
"(",
"$",
"path",
",",
"$",
"separator",
")",
")",
"{",
"$"... | setByPath
@param array|\ArrayAccess &$data
@param string $path
@param mixed $value
@param string $separator
@return boolean | [
"setByPath"
] | train | https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Helpers/ArrayHelper.php#L428-L460 |
heidelpay/PhpDoc | src/phpDocumentor/Descriptor/Builder/Reflector/Tags/VarAssembler.php | VarAssembler.create | public function create($data)
{
$descriptor = new VarDescriptor($data->getName());
$descriptor->setDescription($data->getDescription());
$descriptor->setVariableName($data->getVariableName());
$types = $this->builder->buildDescriptor(
new Collection($data->getVariableNam... | php | public function create($data)
{
$descriptor = new VarDescriptor($data->getName());
$descriptor->setDescription($data->getDescription());
$descriptor->setVariableName($data->getVariableName());
$types = $this->builder->buildDescriptor(
new Collection($data->getVariableNam... | [
"public",
"function",
"create",
"(",
"$",
"data",
")",
"{",
"$",
"descriptor",
"=",
"new",
"VarDescriptor",
"(",
"$",
"data",
"->",
"getName",
"(",
")",
")",
";",
"$",
"descriptor",
"->",
"setDescription",
"(",
"$",
"data",
"->",
"getDescription",
"(",
... | Creates a new Descriptor from the given Reflector.
@param VarTag $data
@return VarDescriptor | [
"Creates",
"a",
"new",
"Descriptor",
"from",
"the",
"given",
"Reflector",
"."
] | train | https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Descriptor/Builder/Reflector/Tags/VarAssembler.php#L34-L46 |
eghojansu/moe | src/tools/web/google/StaticMap.php | StaticMap.dump | function dump() {
$fw=Base::instance();
$web=Web::instance();
$out='';
return ($req=$web->request(
self::URL_Static.'?'.array_reduce(
$this->query,
function($out,$item) {
return ($out.=($out?'&':'').
urlencode($item[0]).'='.urlencode($item[1]));
}
))) && $req['body']?$req['body']:FA... | php | function dump() {
$fw=Base::instance();
$web=Web::instance();
$out='';
return ($req=$web->request(
self::URL_Static.'?'.array_reduce(
$this->query,
function($out,$item) {
return ($out.=($out?'&':'').
urlencode($item[0]).'='.urlencode($item[1]));
}
))) && $req['body']?$req['body']:FA... | [
"function",
"dump",
"(",
")",
"{",
"$",
"fw",
"=",
"Base",
"::",
"instance",
"(",
")",
";",
"$",
"web",
"=",
"Web",
"::",
"instance",
"(",
")",
";",
"$",
"out",
"=",
"''",
";",
"return",
"(",
"$",
"req",
"=",
"$",
"web",
"->",
"request",
"(",... | Generate map
@return string | [
"Generate",
"map"
] | train | https://github.com/eghojansu/moe/blob/f58ec75a3116d1a572782256e2b38bb9aab95e3c/src/tools/web/google/StaticMap.php#L34-L46 |
zicht/z | src/Zicht/Tool/Script/Parser/Expression.php | Expression.parse | public function parse(TokenStream $stream)
{
if ($stream->match(Token::OPERATOR, array('!', '-'))) {
$value = $stream->current()->value;
$stream->next();
$ret = new Op\Unary($value, $this->parse($stream));
} elseif ($stream->match(Token::KEYWORD, array('true', 'fa... | php | public function parse(TokenStream $stream)
{
if ($stream->match(Token::OPERATOR, array('!', '-'))) {
$value = $stream->current()->value;
$stream->next();
$ret = new Op\Unary($value, $this->parse($stream));
} elseif ($stream->match(Token::KEYWORD, array('true', 'fa... | [
"public",
"function",
"parse",
"(",
"TokenStream",
"$",
"stream",
")",
"{",
"if",
"(",
"$",
"stream",
"->",
"match",
"(",
"Token",
"::",
"OPERATOR",
",",
"array",
"(",
"'!'",
",",
"'-'",
")",
")",
")",
"{",
"$",
"value",
"=",
"$",
"stream",
"->",
... | Does a recursive descent parsing of the token stream and returns the resulting node.
@param \Zicht\Tool\Script\TokenStream $stream
@return \Zicht\Tool\Script\Node\Node | [
"Does",
"a",
"recursive",
"descent",
"parsing",
"of",
"the",
"token",
"stream",
"and",
"returns",
"the",
"resulting",
"node",
"."
] | train | https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/Script/Parser/Expression.php#L46-L164 |
FriendsOfApi/phraseapp | src/Model/Key/KeySearchResults.php | KeySearchResults.createFromArray | public static function createFromArray(array $data)
{
$self = new self();
foreach ($data as $searchResult) {
$self->addSearchResult(KeySearchResult::createFromArray($searchResult));
}
return $self;
} | php | public static function createFromArray(array $data)
{
$self = new self();
foreach ($data as $searchResult) {
$self->addSearchResult(KeySearchResult::createFromArray($searchResult));
}
return $self;
} | [
"public",
"static",
"function",
"createFromArray",
"(",
"array",
"$",
"data",
")",
"{",
"$",
"self",
"=",
"new",
"self",
"(",
")",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"searchResult",
")",
"{",
"$",
"self",
"->",
"addSearchResult",
"(",
"KeySea... | @param array $data
@return KeySearchResults | [
"@param",
"array",
"$data"
] | train | https://github.com/FriendsOfApi/phraseapp/blob/1553bf857eb0858f9a7eb905b085864d24f80886/src/Model/Key/KeySearchResults.php#L29-L38 |
kbond/ControllerUtil | src/Template.php | Template.createCached | public static function createCached($template, $sharedMaxAge, $parameters = array(), $statusCode = self::DEFAULT_STATUS_CODE)
{
return new static($template, $parameters, $statusCode, array('s_maxage' => $sharedMaxAge));
} | php | public static function createCached($template, $sharedMaxAge, $parameters = array(), $statusCode = self::DEFAULT_STATUS_CODE)
{
return new static($template, $parameters, $statusCode, array('s_maxage' => $sharedMaxAge));
} | [
"public",
"static",
"function",
"createCached",
"(",
"$",
"template",
",",
"$",
"sharedMaxAge",
",",
"$",
"parameters",
"=",
"array",
"(",
")",
",",
"$",
"statusCode",
"=",
"self",
"::",
"DEFAULT_STATUS_CODE",
")",
"{",
"return",
"new",
"static",
"(",
"$",... | @param string|array $template
@param int $sharedMaxAge
@param array $parameters
@param int $statusCode
@return static | [
"@param",
"string|array",
"$template",
"@param",
"int",
"$sharedMaxAge",
"@param",
"array",
"$parameters",
"@param",
"int",
"$statusCode"
] | train | https://github.com/kbond/ControllerUtil/blob/67375d43c73d6a3f16356f3d683f62b176766e91/src/Template.php#L20-L23 |
eghojansu/moe | src/tools/web/PingBack.php | Pingback.enabled | protected function enabled($url) {
$web=Web::instance();
$req=$web->request($url);
$found=FALSE;
if ($req && $req['body']) {
// Look for pingback header
foreach ($req['headers'] as $header)
if (preg_match('/^X-Pingback:\h*(.+)/',$header,$href)) {
$found=$href[1];
break;
}
if (!$found ... | php | protected function enabled($url) {
$web=Web::instance();
$req=$web->request($url);
$found=FALSE;
if ($req && $req['body']) {
// Look for pingback header
foreach ($req['headers'] as $header)
if (preg_match('/^X-Pingback:\h*(.+)/',$header,$href)) {
$found=$href[1];
break;
}
if (!$found ... | [
"protected",
"function",
"enabled",
"(",
"$",
"url",
")",
"{",
"$",
"web",
"=",
"Web",
"::",
"instance",
"(",
")",
";",
"$",
"req",
"=",
"$",
"web",
"->",
"request",
"(",
"$",
"url",
")",
";",
"$",
"found",
"=",
"FALSE",
";",
"if",
"(",
"$",
... | Return TRUE if URL points to a pingback-enabled resource
@return bool
@param $url | [
"Return",
"TRUE",
"if",
"URL",
"points",
"to",
"a",
"pingback",
"-",
"enabled",
"resource"
] | train | https://github.com/eghojansu/moe/blob/f58ec75a3116d1a572782256e2b38bb9aab95e3c/src/tools/web/PingBack.php#L22-L41 |
eghojansu/moe | src/tools/web/PingBack.php | Pingback.inspect | function inspect($source) {
$fw=Base::instance();
$web=Web::instance();
$parts=parse_url($source);
if (empty($parts['scheme']) || empty($parts['host']) ||
$parts['host']==$fw->get('HOST')) {
$req=$web->request($source);
$doc=new DOMDocument('1.0',$fw->get('ENCODING'));
$doc->stricterrorchecking=FALS... | php | function inspect($source) {
$fw=Base::instance();
$web=Web::instance();
$parts=parse_url($source);
if (empty($parts['scheme']) || empty($parts['host']) ||
$parts['host']==$fw->get('HOST')) {
$req=$web->request($source);
$doc=new DOMDocument('1.0',$fw->get('ENCODING'));
$doc->stricterrorchecking=FALS... | [
"function",
"inspect",
"(",
"$",
"source",
")",
"{",
"$",
"fw",
"=",
"Base",
"::",
"instance",
"(",
")",
";",
"$",
"web",
"=",
"Web",
"::",
"instance",
"(",
")",
";",
"$",
"parts",
"=",
"parse_url",
"(",
"$",
"source",
")",
";",
"if",
"(",
"emp... | Load local page contents, parse HTML anchor tags, find permalinks,
and send XML-RPC calls to corresponding pingback servers
@return NULL
@param $source string | [
"Load",
"local",
"page",
"contents",
"parse",
"HTML",
"anchor",
"tags",
"find",
"permalinks",
"and",
"send",
"XML",
"-",
"RPC",
"calls",
"to",
"corresponding",
"pingback",
"servers"
] | train | https://github.com/eghojansu/moe/blob/f58ec75a3116d1a572782256e2b38bb9aab95e3c/src/tools/web/PingBack.php#L49-L86 |
eghojansu/moe | src/tools/web/PingBack.php | Pingback.listen | function listen($func,$path=NULL) {
$fw=Base::instance();
if (PHP_SAPI!='cli') {
header('X-Powered-By: '.$fw->get('PACKAGE'));
header('Content-Type: application/xml; '.
'charset='.$charset=$fw->get('ENCODING'));
}
if (!$path)
$path=$fw->get('BASE');
$web=Web::instance();
$args=xmlrpc_decode_req... | php | function listen($func,$path=NULL) {
$fw=Base::instance();
if (PHP_SAPI!='cli') {
header('X-Powered-By: '.$fw->get('PACKAGE'));
header('Content-Type: application/xml; '.
'charset='.$charset=$fw->get('ENCODING'));
}
if (!$path)
$path=$fw->get('BASE');
$web=Web::instance();
$args=xmlrpc_decode_req... | [
"function",
"listen",
"(",
"$",
"func",
",",
"$",
"path",
"=",
"NULL",
")",
"{",
"$",
"fw",
"=",
"Base",
"::",
"instance",
"(",
")",
";",
"if",
"(",
"PHP_SAPI",
"!=",
"'cli'",
")",
"{",
"header",
"(",
"'X-Powered-By: '",
".",
"$",
"fw",
"->",
"ge... | Receive ping, check if local page is pingback-enabled, verify
source contents, and return XML-RPC response
@return string
@param $func callback
@param $path string | [
"Receive",
"ping",
"check",
"if",
"local",
"page",
"is",
"pingback",
"-",
"enabled",
"verify",
"source",
"contents",
"and",
"return",
"XML",
"-",
"RPC",
"response"
] | train | https://github.com/eghojansu/moe/blob/f58ec75a3116d1a572782256e2b38bb9aab95e3c/src/tools/web/PingBack.php#L95-L143 |
ekuiter/feature-php | FeaturePhp/Generator/AspectGenerator.php | AspectGenerator.processFileSpecification | protected function processFileSpecification($artifact, $fileSpecification) {
$this->aspectKernel->addAspect(new fphp\Aspect\Aspect($artifact, $fileSpecification));
$this->tracingLinks[] = new fphp\Artifact\TracingLink(
"aspect", $artifact, $fileSpecification->getSourcePlace(), $fileSpecifica... | php | protected function processFileSpecification($artifact, $fileSpecification) {
$this->aspectKernel->addAspect(new fphp\Aspect\Aspect($artifact, $fileSpecification));
$this->tracingLinks[] = new fphp\Artifact\TracingLink(
"aspect", $artifact, $fileSpecification->getSourcePlace(), $fileSpecifica... | [
"protected",
"function",
"processFileSpecification",
"(",
"$",
"artifact",
",",
"$",
"fileSpecification",
")",
"{",
"$",
"this",
"->",
"aspectKernel",
"->",
"addAspect",
"(",
"new",
"fphp",
"\\",
"Aspect",
"\\",
"Aspect",
"(",
"$",
"artifact",
",",
"$",
"fil... | Adds an aspect from a file to the aspect kernel.
@param \FeaturePhp\Artifact\Artifact $artifact
@param \FeaturePhp\Specification\FileSpecification $fileSpecification | [
"Adds",
"an",
"aspect",
"from",
"a",
"file",
"to",
"the",
"aspect",
"kernel",
"."
] | train | https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Generator/AspectGenerator.php#L70-L75 |
ekuiter/feature-php | FeaturePhp/Generator/AspectGenerator.php | AspectGenerator._generateFiles | protected function _generateFiles() {
if ($this->feature && !$this->isSelectedFeature($this->feature)) {
$this->logFile->log(null, "did not add aspect kernel because \"$this->feature\" is not selected");
return;
}
parent::_generateFiles();
$this->files = array_me... | php | protected function _generateFiles() {
if ($this->feature && !$this->isSelectedFeature($this->feature)) {
$this->logFile->log(null, "did not add aspect kernel because \"$this->feature\" is not selected");
return;
}
parent::_generateFiles();
$this->files = array_me... | [
"protected",
"function",
"_generateFiles",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"feature",
"&&",
"!",
"$",
"this",
"->",
"isSelectedFeature",
"(",
"$",
"this",
"->",
"feature",
")",
")",
"{",
"$",
"this",
"->",
"logFile",
"->",
"log",
"(",
"n... | Generates the aspect files and the aspect kernel. | [
"Generates",
"the",
"aspect",
"files",
"and",
"the",
"aspect",
"kernel",
"."
] | train | https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Generator/AspectGenerator.php#L80-L89 |
jakubkratina/larachartie | src/DataTable/Factory/RowsFactory.php | RowsFactory.create | public function create(array $values, int $columns)
{
if (self::areSplatted($values) === true) {
$values = $values[0];
}
// TODO only at LineChartFormatter
// if (count($values) !== $columns) {
// throw new InvalidCellsCountException(count($values), $columns);
// }
return (new Row($this->cells))->addC... | php | public function create(array $values, int $columns)
{
if (self::areSplatted($values) === true) {
$values = $values[0];
}
// TODO only at LineChartFormatter
// if (count($values) !== $columns) {
// throw new InvalidCellsCountException(count($values), $columns);
// }
return (new Row($this->cells))->addC... | [
"public",
"function",
"create",
"(",
"array",
"$",
"values",
",",
"int",
"$",
"columns",
")",
"{",
"if",
"(",
"self",
"::",
"areSplatted",
"(",
"$",
"values",
")",
"===",
"true",
")",
"{",
"$",
"values",
"=",
"$",
"values",
"[",
"0",
"]",
";",
"}... | {@inheritdoc} | [
"{"
] | train | https://github.com/jakubkratina/larachartie/blob/96c535650d61a2a6c1c1b12d374e5e59d33239f6/src/DataTable/Factory/RowsFactory.php#L35-L47 |
kbond/ControllerUtil | src/EventListener/ConvertExceptionListener.php | ConvertExceptionListener.findStatusCode | private function findStatusCode(\Exception $exception)
{
$exceptionClass = get_class($exception);
foreach ($this->exceptionClassMap as $originalExceptionClass => $statusCode) {
if ($exceptionClass === $originalExceptionClass || is_subclass_of($exceptionClass, $originalExceptionClass)) {... | php | private function findStatusCode(\Exception $exception)
{
$exceptionClass = get_class($exception);
foreach ($this->exceptionClassMap as $originalExceptionClass => $statusCode) {
if ($exceptionClass === $originalExceptionClass || is_subclass_of($exceptionClass, $originalExceptionClass)) {... | [
"private",
"function",
"findStatusCode",
"(",
"\\",
"Exception",
"$",
"exception",
")",
"{",
"$",
"exceptionClass",
"=",
"get_class",
"(",
"$",
"exception",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"exceptionClassMap",
"as",
"$",
"originalExceptionClass",
... | @param \Exception $exception
@return int|null | [
"@param",
"\\",
"Exception",
"$exception"
] | train | https://github.com/kbond/ControllerUtil/blob/67375d43c73d6a3f16356f3d683f62b176766e91/src/EventListener/ConvertExceptionListener.php#L54-L65 |
willhoffmann/domuserp-php | src/Resources/Addresses/Secondary/Neighborhoods.php | Neighborhoods.getList | public function getList(array $query = [])
{
$resource = self::DOMUSERP_API_OPERACIONAL . '/' . $this->cityId .'/bairros';
$list = $this->pagination($resource);
return $list;
} | php | public function getList(array $query = [])
{
$resource = self::DOMUSERP_API_OPERACIONAL . '/' . $this->cityId .'/bairros';
$list = $this->pagination($resource);
return $list;
} | [
"public",
"function",
"getList",
"(",
"array",
"$",
"query",
"=",
"[",
"]",
")",
"{",
"$",
"resource",
"=",
"self",
"::",
"DOMUSERP_API_OPERACIONAL",
".",
"'/'",
".",
"$",
"this",
"->",
"cityId",
".",
"'/bairros'",
";",
"$",
"list",
"=",
"$",
"this",
... | List of neighborhoods
@param array $query
@return array|string
@throws \GuzzleHttp\Exception\GuzzleException | [
"List",
"of",
"neighborhoods"
] | train | https://github.com/willhoffmann/domuserp-php/blob/44e77a4f02b0252bc26cae4c0e6b2b7d578f10a6/src/Resources/Addresses/Secondary/Neighborhoods.php#L36-L42 |
willhoffmann/domuserp-php | src/Resources/Addresses/Secondary/Neighborhoods.php | Neighborhoods.save | public function save(DataReceiver $data)
{
$resource = self::DOMUSERP_API_OPERACIONAL . '/enderecos/localidade/'. $this->cityId .'/bairros';
return $this->execute(self::HTTP_POST, $resource, ['json' => $data->toArray()]);
} | php | public function save(DataReceiver $data)
{
$resource = self::DOMUSERP_API_OPERACIONAL . '/enderecos/localidade/'. $this->cityId .'/bairros';
return $this->execute(self::HTTP_POST, $resource, ['json' => $data->toArray()]);
} | [
"public",
"function",
"save",
"(",
"DataReceiver",
"$",
"data",
")",
"{",
"$",
"resource",
"=",
"self",
"::",
"DOMUSERP_API_OPERACIONAL",
".",
"'/enderecos/localidade/'",
".",
"$",
"this",
"->",
"cityId",
".",
"'/bairros'",
";",
"return",
"$",
"this",
"->",
... | Send the save request
@param DataReceiver $data
@return string
@throws \GuzzleHttp\Exception\GuzzleException | [
"Send",
"the",
"save",
"request"
] | train | https://github.com/willhoffmann/domuserp-php/blob/44e77a4f02b0252bc26cae4c0e6b2b7d578f10a6/src/Resources/Addresses/Secondary/Neighborhoods.php#L87-L91 |
zhouyl/mellivora | Mellivora/Database/Concerns/ManagesTransactions.php | ManagesTransactions.transaction | public function transaction(Closure $callback, $attempts = 1)
{
for ($currentAttempt = 1; $currentAttempt <= $attempts; ++$currentAttempt) {
$this->beginTransaction();
// We'll simply execute the given callback within a try / catch block and if we
// catch any exception ... | php | public function transaction(Closure $callback, $attempts = 1)
{
for ($currentAttempt = 1; $currentAttempt <= $attempts; ++$currentAttempt) {
$this->beginTransaction();
// We'll simply execute the given callback within a try / catch block and if we
// catch any exception ... | [
"public",
"function",
"transaction",
"(",
"Closure",
"$",
"callback",
",",
"$",
"attempts",
"=",
"1",
")",
"{",
"for",
"(",
"$",
"currentAttempt",
"=",
"1",
";",
"$",
"currentAttempt",
"<=",
"$",
"attempts",
";",
"++",
"$",
"currentAttempt",
")",
"{",
... | Execute a Closure within a transaction.
@param \Closure $callback
@param int $attempts
@throws \Exception|\Throwable
@return mixed | [
"Execute",
"a",
"Closure",
"within",
"a",
"transaction",
"."
] | train | https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Database/Concerns/ManagesTransactions.php#L21-L50 |
zhouyl/mellivora | Mellivora/Database/Concerns/ManagesTransactions.php | ManagesTransactions.handleTransactionException | protected function handleTransactionException($e, $currentAttempt, $maxAttempts)
{
// On a deadlock, MySQL rolls back the entire transaction so we can't just
// retry the query. We have to throw this exception all the way out and
// let the developer handle it in another way. We will decreme... | php | protected function handleTransactionException($e, $currentAttempt, $maxAttempts)
{
// On a deadlock, MySQL rolls back the entire transaction so we can't just
// retry the query. We have to throw this exception all the way out and
// let the developer handle it in another way. We will decreme... | [
"protected",
"function",
"handleTransactionException",
"(",
"$",
"e",
",",
"$",
"currentAttempt",
",",
"$",
"maxAttempts",
")",
"{",
"// On a deadlock, MySQL rolls back the entire transaction so we can't just",
"// retry the query. We have to throw this exception all the way out and",
... | Handle an exception encountered when running a transacted statement.
@param \Exception $e
@param int $currentAttempt
@param int $maxAttempts
@throws \Exception
@return void | [
"Handle",
"an",
"exception",
"encountered",
"when",
"running",
"a",
"transacted",
"statement",
"."
] | train | https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Database/Concerns/ManagesTransactions.php#L63-L86 |
zhouyl/mellivora | Mellivora/Database/Concerns/ManagesTransactions.php | ManagesTransactions.createTransaction | protected function createTransaction()
{
if ($this->transactions === 0) {
try {
$this->getPdo()->beginTransaction();
} catch (Exception $e) {
$this->handleBeginTransactionException($e);
}
} elseif ($this->transactions >= 1 && $this-... | php | protected function createTransaction()
{
if ($this->transactions === 0) {
try {
$this->getPdo()->beginTransaction();
} catch (Exception $e) {
$this->handleBeginTransactionException($e);
}
} elseif ($this->transactions >= 1 && $this-... | [
"protected",
"function",
"createTransaction",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"transactions",
"===",
"0",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"getPdo",
"(",
")",
"->",
"beginTransaction",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",... | Create a transaction within the database.
@return void | [
"Create",
"a",
"transaction",
"within",
"the",
"database",
"."
] | train | https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Database/Concerns/ManagesTransactions.php#L109-L120 |
zhouyl/mellivora | Mellivora/Database/Concerns/ManagesTransactions.php | ManagesTransactions.rollBack | public function rollBack($toLevel = null)
{
// We allow developers to rollback to a certain transaction level. We will verify
// that this given transaction level is valid before attempting to rollback to
// that level. If it's not we will just return out and not attempt anything.
$t... | php | public function rollBack($toLevel = null)
{
// We allow developers to rollback to a certain transaction level. We will verify
// that this given transaction level is valid before attempting to rollback to
// that level. If it's not we will just return out and not attempt anything.
$t... | [
"public",
"function",
"rollBack",
"(",
"$",
"toLevel",
"=",
"null",
")",
"{",
"// We allow developers to rollback to a certain transaction level. We will verify",
"// that this given transaction level is valid before attempting to rollback to",
"// that level. If it's not we will just return... | Rollback the active database transaction.
@param null|int $toLevel
@return void | [
"Rollback",
"the",
"active",
"database",
"transaction",
"."
] | train | https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Database/Concerns/ManagesTransactions.php#L177-L198 |
zhouyl/mellivora | Mellivora/Database/Concerns/ManagesTransactions.php | ManagesTransactions.performRollBack | protected function performRollBack($toLevel)
{
if ($toLevel === 0) {
$this->getPdo()->rollBack();
} elseif ($this->queryGrammar->supportsSavepoints()) {
$this->getPdo()->exec(
$this->queryGrammar->compileSavepointRollBack('trans' . ($toLevel + 1))
... | php | protected function performRollBack($toLevel)
{
if ($toLevel === 0) {
$this->getPdo()->rollBack();
} elseif ($this->queryGrammar->supportsSavepoints()) {
$this->getPdo()->exec(
$this->queryGrammar->compileSavepointRollBack('trans' . ($toLevel + 1))
... | [
"protected",
"function",
"performRollBack",
"(",
"$",
"toLevel",
")",
"{",
"if",
"(",
"$",
"toLevel",
"===",
"0",
")",
"{",
"$",
"this",
"->",
"getPdo",
"(",
")",
"->",
"rollBack",
"(",
")",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"queryGrammar",... | Perform a rollback within the database.
@param int $toLevel
@return void | [
"Perform",
"a",
"rollback",
"within",
"the",
"database",
"."
] | train | https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Database/Concerns/ManagesTransactions.php#L207-L216 |
wenbinye/PhalconX | src/Mvc/Model.php | Model.findPk | public static function findPk($pk)
{
if (empty($pk)) {
return false;
}
if (is_array($pk)) {
$conditions = '';
$sep = '';
foreach ($pk as $name => $value) {
$conditions .= $sep . "$name=:$name:";
$sep = ' AND ';
... | php | public static function findPk($pk)
{
if (empty($pk)) {
return false;
}
if (is_array($pk)) {
$conditions = '';
$sep = '';
foreach ($pk as $name => $value) {
$conditions .= $sep . "$name=:$name:";
$sep = ' AND ';
... | [
"public",
"static",
"function",
"findPk",
"(",
"$",
"pk",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"pk",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"pk",
")",
")",
"{",
"$",
"conditions",
"=",
"''",
";",
"$",
... | Finds model by primary key
@param string|array | [
"Finds",
"model",
"by",
"primary",
"key"
] | train | https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Mvc/Model.php#L16-L36 |
wenbinye/PhalconX | src/Mvc/Model.php | Model.isChanged | public function isChanged()
{
$snapshot = $this->_snapshot;
if (!is_array($snapshot)) {
return true;
}
$metadata = $this->getModelsMetaData();
$attrs = $metadata->getNonPrimaryKeyAttributes($this);
$automatic = $metadata->getAutomaticUpdateAttributes($this... | php | public function isChanged()
{
$snapshot = $this->_snapshot;
if (!is_array($snapshot)) {
return true;
}
$metadata = $this->getModelsMetaData();
$attrs = $metadata->getNonPrimaryKeyAttributes($this);
$automatic = $metadata->getAutomaticUpdateAttributes($this... | [
"public",
"function",
"isChanged",
"(",
")",
"{",
"$",
"snapshot",
"=",
"$",
"this",
"->",
"_snapshot",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"snapshot",
")",
")",
"{",
"return",
"true",
";",
"}",
"$",
"metadata",
"=",
"$",
"this",
"->",
"getM... | Checks whether the model changes
@return bool | [
"Checks",
"whether",
"the",
"model",
"changes"
] | train | https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Mvc/Model.php#L43-L88 |
nabab/bbn | src/bbn/db.php | db._get_cache | private function _get_cache($item, $mode = 'columns', $force = false): ?array
{
$cache_name = $this->_db_cache_name($item, $mode);
if ( $force && isset($this->cache[$cache_name]) ){
unset($this->cache[$cache_name]);
}
if ( !isset($this->cache[$cache_name]) ){
if ( $force || !($tmp = $this-... | php | private function _get_cache($item, $mode = 'columns', $force = false): ?array
{
$cache_name = $this->_db_cache_name($item, $mode);
if ( $force && isset($this->cache[$cache_name]) ){
unset($this->cache[$cache_name]);
}
if ( !isset($this->cache[$cache_name]) ){
if ( $force || !($tmp = $this-... | [
"private",
"function",
"_get_cache",
"(",
"$",
"item",
",",
"$",
"mode",
"=",
"'columns'",
",",
"$",
"force",
"=",
"false",
")",
":",
"?",
"array",
"{",
"$",
"cache_name",
"=",
"$",
"this",
"->",
"_db_cache_name",
"(",
"$",
"item",
",",
"$",
"mode",
... | Return the table's structure's array, either from the cache or from _modelize().
@param $item
@param string $mode
@param bool $force
@return array|null | [
"Return",
"the",
"table",
"s",
"structure",
"s",
"array",
"either",
"from",
"the",
"cache",
"or",
"from",
"_modelize",
"()",
"."
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/db.php#L244-L283 |
nabab/bbn | src/bbn/db.php | db._add_query | private function _add_query($hash, $statement, $kind, $placeholders, $options)
{
$this->queries[$hash] = [
'sql' => $statement,
'kind' => $kind,
'write' => \in_array($kind, self::$write_kinds, true),
'structure' => \in_array($kind, self::$structure_kinds, true),
'placeholders' => $pl... | php | private function _add_query($hash, $statement, $kind, $placeholders, $options)
{
$this->queries[$hash] = [
'sql' => $statement,
'kind' => $kind,
'write' => \in_array($kind, self::$write_kinds, true),
'structure' => \in_array($kind, self::$structure_kinds, true),
'placeholders' => $pl... | [
"private",
"function",
"_add_query",
"(",
"$",
"hash",
",",
"$",
"statement",
",",
"$",
"kind",
",",
"$",
"placeholders",
",",
"$",
"options",
")",
"{",
"$",
"this",
"->",
"queries",
"[",
"$",
"hash",
"]",
"=",
"[",
"'sql'",
"=>",
"$",
"statement",
... | Adds the specs of a query to the $queries object.
@param string $hash The hash of the statement.
@param string $statement The SQL full statement.
@param string $kind The type of statement.
@param int $placeholders The number of placeholders.
@param array $options The driver options. | [
"Adds",
"the",
"specs",
"of",
"a",
"query",
"to",
"the",
"$queries",
"object",
"."
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/db.php#L320-L349 |
nabab/bbn | src/bbn/db.php | db._make_hash | private function _make_hash(): string
{
$args = \func_get_args();
if ( (\count($args) === 1) && \is_array($args[0]) ){
$args = $args[0];
}
$st = '';
foreach ( $args as $a ){
$st .= \is_array($a) ? serialize($a) : '--'.$a.'--';
}
return $this->hash_contour.md5($st).$this->hash_c... | php | private function _make_hash(): string
{
$args = \func_get_args();
if ( (\count($args) === 1) && \is_array($args[0]) ){
$args = $args[0];
}
$st = '';
foreach ( $args as $a ){
$st .= \is_array($a) ? serialize($a) : '--'.$a.'--';
}
return $this->hash_contour.md5($st).$this->hash_c... | [
"private",
"function",
"_make_hash",
"(",
")",
":",
"string",
"{",
"$",
"args",
"=",
"\\",
"func_get_args",
"(",
")",
";",
"if",
"(",
"(",
"\\",
"count",
"(",
"$",
"args",
")",
"===",
"1",
")",
"&&",
"\\",
"is_array",
"(",
"$",
"args",
"[",
"0",
... | Makes a string that will be the id of the request.
@return string | [
"Makes",
"a",
"string",
"that",
"will",
"be",
"the",
"id",
"of",
"the",
"request",
"."
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/db.php#L357-L368 |
nabab/bbn | src/bbn/db.php | db._trigger | private function _trigger(array $cfg): array
{
if ( $this->triggers_disabled ){
$cfg['run'] = 1;
$cfg['trig'] = 1;
return $cfg;
}
if ( !isset($cfg['trig']) ){
$cfg['trig'] = 1;
}
if ( !isset($cfg['run']) ){
$cfg['run'] = 1;
}
if ( !empty($cfg['tables']) && !em... | php | private function _trigger(array $cfg): array
{
if ( $this->triggers_disabled ){
$cfg['run'] = 1;
$cfg['trig'] = 1;
return $cfg;
}
if ( !isset($cfg['trig']) ){
$cfg['trig'] = 1;
}
if ( !isset($cfg['run']) ){
$cfg['run'] = 1;
}
if ( !empty($cfg['tables']) && !em... | [
"private",
"function",
"_trigger",
"(",
"array",
"$",
"cfg",
")",
":",
"array",
"{",
"if",
"(",
"$",
"this",
"->",
"triggers_disabled",
")",
"{",
"$",
"cfg",
"[",
"'run'",
"]",
"=",
"1",
";",
"$",
"cfg",
"[",
"'trig'",
"]",
"=",
"1",
";",
"return... | Launches a function before or after
@param array $cfg
@return array | [
"Launches",
"a",
"function",
"before",
"or",
"after"
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/db.php#L376-L410 |
nabab/bbn | src/bbn/db.php | db._add_primary | private function _add_primary(array &$cfg): void
{
// Inserting a row without primary when primary is needed and no auto-increment
if (
!empty($cfg['primary']) &&
empty($cfg['auto_increment']) &&
(($idx = array_search($cfg['primary'], $cfg['fields'], true)) > -1) &&
(count($cfg['values... | php | private function _add_primary(array &$cfg): void
{
// Inserting a row without primary when primary is needed and no auto-increment
if (
!empty($cfg['primary']) &&
empty($cfg['auto_increment']) &&
(($idx = array_search($cfg['primary'], $cfg['fields'], true)) > -1) &&
(count($cfg['values... | [
"private",
"function",
"_add_primary",
"(",
"array",
"&",
"$",
"cfg",
")",
":",
"void",
"{",
"// Inserting a row without primary when primary is needed and no auto-increment",
"if",
"(",
"!",
"empty",
"(",
"$",
"cfg",
"[",
"'primary'",
"]",
")",
"&&",
"empty",
"("... | Adds a random primary value when it is absent from the set and present in the fields
@param array $cfg | [
"Adds",
"a",
"random",
"primary",
"value",
"when",
"it",
"is",
"absent",
"from",
"the",
"set",
"and",
"present",
"in",
"the",
"fields"
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/db.php#L436-L467 |
nabab/bbn | src/bbn/db.php | db._treat_arguments | private function _treat_arguments($cfg): array
{
while ( isset($cfg[0]) && \is_array($cfg[0]) ){
$cfg = $cfg[0];
}
if (
\is_array($cfg) &&
array_key_exists('tables', $cfg) &&
!empty($cfg['bbn_db_treated']) &&
($cfg['bbn_db_treated'] === true)
){
return $cfg;
}
... | php | private function _treat_arguments($cfg): array
{
while ( isset($cfg[0]) && \is_array($cfg[0]) ){
$cfg = $cfg[0];
}
if (
\is_array($cfg) &&
array_key_exists('tables', $cfg) &&
!empty($cfg['bbn_db_treated']) &&
($cfg['bbn_db_treated'] === true)
){
return $cfg;
}
... | [
"private",
"function",
"_treat_arguments",
"(",
"$",
"cfg",
")",
":",
"array",
"{",
"while",
"(",
"isset",
"(",
"$",
"cfg",
"[",
"0",
"]",
")",
"&&",
"\\",
"is_array",
"(",
"$",
"cfg",
"[",
"0",
"]",
")",
")",
"{",
"$",
"cfg",
"=",
"$",
"cfg",
... | Normalizes arguments by making it a uniform array.
<ul><h3>The array will have the following indexes:</h3>
<li>fields</li>
<li>where</li>
<li>filters</li>
<li>order</li>
<li>limit</li>
<li>start</li>
<li>join</li>
<li>group_by</li>
<li>having</li>
<li>values</li>
<li>hashed_join</li>
<li>hashed_where</li>
<li>hashed_ha... | [
"Normalizes",
"arguments",
"by",
"making",
"it",
"a",
"uniform",
"array",
".",
"<ul",
">",
"<h3",
">",
"The",
"array",
"will",
"have",
"the",
"following",
"indexes",
":",
"<",
"/",
"h3",
">",
"<li",
">",
"fields<",
"/",
"li",
">",
"<li",
">",
"where<... | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/db.php#L582-L750 |
nabab/bbn | src/bbn/db.php | db.retrieve_query | public function retrieve_query(string $hash): ?array
{
if ( isset($this->queries[$hash]) ){
if ( \is_string($this->queries[$hash]) ){
$hash = $this->queries[$hash];
}
return $this->queries[$hash];
}
return null;
} | php | public function retrieve_query(string $hash): ?array
{
if ( isset($this->queries[$hash]) ){
if ( \is_string($this->queries[$hash]) ){
$hash = $this->queries[$hash];
}
return $this->queries[$hash];
}
return null;
} | [
"public",
"function",
"retrieve_query",
"(",
"string",
"$",
"hash",
")",
":",
"?",
"array",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"queries",
"[",
"$",
"hash",
"]",
")",
")",
"{",
"if",
"(",
"\\",
"is_string",
"(",
"$",
"this",
"->",
"q... | Retrieves a query array based on its hash.
@param string $hash
@return array|null | [
"Retrieves",
"a",
"query",
"array",
"based",
"on",
"its",
"hash",
"."
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/db.php#L880-L889 |
nabab/bbn | src/bbn/db.php | db.filter_filters | public function filter_filters(array $cfg, $field, $operator = null): ?array
{
if ( isset($cfg['filters']) ){
$f = function($cond, &$res = []) use (&$f, $field, $operator){
foreach ( $cond as $c ){
if ( isset($c['conditions']) ){
$f($c['conditions'], $res);
}
... | php | public function filter_filters(array $cfg, $field, $operator = null): ?array
{
if ( isset($cfg['filters']) ){
$f = function($cond, &$res = []) use (&$f, $field, $operator){
foreach ( $cond as $c ){
if ( isset($c['conditions']) ){
$f($c['conditions'], $res);
}
... | [
"public",
"function",
"filter_filters",
"(",
"array",
"$",
"cfg",
",",
"$",
"field",
",",
"$",
"operator",
"=",
"null",
")",
":",
"?",
"array",
"{",
"if",
"(",
"isset",
"(",
"$",
"cfg",
"[",
"'filters'",
"]",
")",
")",
"{",
"$",
"f",
"=",
"functi... | Retrieve an array of specific filters among the existing ones.
@param array $cfg
@param $field
@param null $operator
@return array|null | [
"Retrieve",
"an",
"array",
"of",
"specific",
"filters",
"among",
"the",
"existing",
"ones",
"."
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/db.php#L1016-L1033 |
nabab/bbn | src/bbn/db.php | db.error | public function error($e): void
{
$this->has_error = true;
self::has_error();
$msg = [
self::$line,
self::get_log_line('ERROR DB!'),
self::$line
];
if ( \is_string($e) ){
$msg[] = self::get_log_line('USER MESSAGE');
$msg[] = $e;
}
else if ( method_exists($e, '... | php | public function error($e): void
{
$this->has_error = true;
self::has_error();
$msg = [
self::$line,
self::get_log_line('ERROR DB!'),
self::$line
];
if ( \is_string($e) ){
$msg[] = self::get_log_line('USER MESSAGE');
$msg[] = $e;
}
else if ( method_exists($e, '... | [
"public",
"function",
"error",
"(",
"$",
"e",
")",
":",
"void",
"{",
"$",
"this",
"->",
"has_error",
"=",
"true",
";",
"self",
"::",
"has_error",
"(",
")",
";",
"$",
"msg",
"=",
"[",
"self",
"::",
"$",
"line",
",",
"self",
"::",
"get_log_line",
"... | Set an error and acts appropriately based oon the error mode
@param $e
@return void | [
"Set",
"an",
"error",
"and",
"acts",
"appropriately",
"based",
"oon",
"the",
"error",
"mode"
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/db.php#L1357-L1403 |
nabab/bbn | src/bbn/db.php | db.check | public function check(): bool
{
if ( $this->current !== null ){
// if $on_error is set to E_CONTINUE returns true
if ( $this->on_error === self::E_CONTINUE ){
return true;
}
// If any connection has an error with mode E_STOP_ALL
if ( self::$has_error_all && ($this->on_error !... | php | public function check(): bool
{
if ( $this->current !== null ){
// if $on_error is set to E_CONTINUE returns true
if ( $this->on_error === self::E_CONTINUE ){
return true;
}
// If any connection has an error with mode E_STOP_ALL
if ( self::$has_error_all && ($this->on_error !... | [
"public",
"function",
"check",
"(",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"this",
"->",
"current",
"!==",
"null",
")",
"{",
"// if $on_error is set to E_CONTINUE returns true",
"if",
"(",
"$",
"this",
"->",
"on_error",
"===",
"self",
"::",
"E_CONTINUE",
")"... | Checks if the database is ready to process a query.
```php
bbn\x::dump($db->check());
// (bool)
```
@return bool | [
"Checks",
"if",
"the",
"database",
"is",
"ready",
"to",
"process",
"a",
"query",
"."
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/db.php#L1414-L1432 |
nabab/bbn | src/bbn/db.php | db.log | public function log($st): self
{
$args = \func_get_args();
foreach ( $args as $a ){
x::log($a, 'db');
}
return $this;
} | php | public function log($st): self
{
$args = \func_get_args();
foreach ( $args as $a ){
x::log($a, 'db');
}
return $this;
} | [
"public",
"function",
"log",
"(",
"$",
"st",
")",
":",
"self",
"{",
"$",
"args",
"=",
"\\",
"func_get_args",
"(",
")",
";",
"foreach",
"(",
"$",
"args",
"as",
"$",
"a",
")",
"{",
"x",
"::",
"log",
"(",
"$",
"a",
",",
"'db'",
")",
";",
"}",
... | Writes in data/logs/db.log.
```php
$db->$db->log('test');
```
@param mixed $st
@return db | [
"Writes",
"in",
"data",
"/",
"logs",
"/",
"db",
".",
"log",
"."
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/db.php#L1443-L1450 |
nabab/bbn | src/bbn/db.php | db.clear_cache | public function clear_cache($item, $mode): self
{
$cache_name = $this->_cache_name($item, $mode);
if ( $this->cache_has($cache_name) ){
$this->cache_delete($cache_name);
}
return $this;
} | php | public function clear_cache($item, $mode): self
{
$cache_name = $this->_cache_name($item, $mode);
if ( $this->cache_has($cache_name) ){
$this->cache_delete($cache_name);
}
return $this;
} | [
"public",
"function",
"clear_cache",
"(",
"$",
"item",
",",
"$",
"mode",
")",
":",
"self",
"{",
"$",
"cache_name",
"=",
"$",
"this",
"->",
"_cache_name",
"(",
"$",
"item",
",",
"$",
"mode",
")",
";",
"if",
"(",
"$",
"this",
"->",
"cache_has",
"(",
... | Deletes a specific item from the cache.
```php
bbn\x::dump($db->clear_cache('db_example','tables'));
// (db)
```
@param string $item 'db_name' or 'table_name'
@param string $mode 'columns','tables' or'databases'
@return self | [
"Deletes",
"a",
"specific",
"item",
"from",
"the",
"cache",
"."
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/db.php#L1495-L1502 |
nabab/bbn | src/bbn/db.php | db.stop_fancy_stuff | public function stop_fancy_stuff(): self
{
$this->setAttribute(\PDO::ATTR_STATEMENT_CLASS, [\PDOStatement::class]);
$this->fancy = false;
return $this;
} | php | public function stop_fancy_stuff(): self
{
$this->setAttribute(\PDO::ATTR_STATEMENT_CLASS, [\PDOStatement::class]);
$this->fancy = false;
return $this;
} | [
"public",
"function",
"stop_fancy_stuff",
"(",
")",
":",
"self",
"{",
"$",
"this",
"->",
"setAttribute",
"(",
"\\",
"PDO",
"::",
"ATTR_STATEMENT_CLASS",
",",
"[",
"\\",
"PDOStatement",
"::",
"class",
"]",
")",
";",
"$",
"this",
"->",
"fancy",
"=",
"false... | Stops fancy stuff.
```php
$db->stop_fancy_stuff();
// (void)
```
@return db | [
"Stops",
"fancy",
"stuff",
"."
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/db.php#L1530-L1535 |
nabab/bbn | src/bbn/db.php | db.start_fancy_stuff | public function start_fancy_stuff(): self
{
$this->setAttribute(\PDO::ATTR_STATEMENT_CLASS, [db\query::class, [$this]]);
$this->fancy = 1;
return $this;
} | php | public function start_fancy_stuff(): self
{
$this->setAttribute(\PDO::ATTR_STATEMENT_CLASS, [db\query::class, [$this]]);
$this->fancy = 1;
return $this;
} | [
"public",
"function",
"start_fancy_stuff",
"(",
")",
":",
"self",
"{",
"$",
"this",
"->",
"setAttribute",
"(",
"\\",
"PDO",
"::",
"ATTR_STATEMENT_CLASS",
",",
"[",
"db",
"\\",
"query",
"::",
"class",
",",
"[",
"$",
"this",
"]",
"]",
")",
";",
"$",
"t... | Starts fancy stuff.
```php
$db->start_fancy_stuff();
// (void)
```
@return db | [
"Starts",
"fancy",
"stuff",
"."
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/db.php#L1546-L1551 |
nabab/bbn | src/bbn/db.php | db.set_trigger | public function set_trigger(callable $function, $kind = null, $moment = null, $tables = '*' ): self
{
$kinds = ['SELECT', 'INSERT', 'UPDATE', 'DELETE'];
$moments = ['before', 'after'];
if ( empty($kind) ){
$kind = $kinds;
}
else if ( !\is_array($kind) ){
$kind = (array)strtoupper($kind... | php | public function set_trigger(callable $function, $kind = null, $moment = null, $tables = '*' ): self
{
$kinds = ['SELECT', 'INSERT', 'UPDATE', 'DELETE'];
$moments = ['before', 'after'];
if ( empty($kind) ){
$kind = $kinds;
}
else if ( !\is_array($kind) ){
$kind = (array)strtoupper($kind... | [
"public",
"function",
"set_trigger",
"(",
"callable",
"$",
"function",
",",
"$",
"kind",
"=",
"null",
",",
"$",
"moment",
"=",
"null",
",",
"$",
"tables",
"=",
"'*'",
")",
":",
"self",
"{",
"$",
"kinds",
"=",
"[",
"'SELECT'",
",",
"'INSERT'",
",",
... | Apply a function each time the methods $kind are used
@param callable $function
@param array|string $kind select|insert|update|delete
@param array|string $moment before|after
@param null|string|array $tables database's table(s) name(s)
@return db | [
"Apply",
"a",
"function",
"each",
"time",
"the",
"methods",
"$kind",
"are",
"used"
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/db.php#L1639-L1682 |
nabab/bbn | src/bbn/db.php | db.get_foreign_keys | public function get_foreign_keys(string $col, string $table, string $db = null): array
{
if ( !$db ){
$db = $this->current;
}
$res = [];
$model = $this->modelize();
foreach ( $model as $tn => $m ){
foreach ( $m['keys'] as $k => $t ){
if ( ($t['ref_table'] === $table) &&
... | php | public function get_foreign_keys(string $col, string $table, string $db = null): array
{
if ( !$db ){
$db = $this->current;
}
$res = [];
$model = $this->modelize();
foreach ( $model as $tn => $m ){
foreach ( $m['keys'] as $k => $t ){
if ( ($t['ref_table'] === $table) &&
... | [
"public",
"function",
"get_foreign_keys",
"(",
"string",
"$",
"col",
",",
"string",
"$",
"table",
",",
"string",
"$",
"db",
"=",
"null",
")",
":",
"array",
"{",
"if",
"(",
"!",
"$",
"db",
")",
"{",
"$",
"db",
"=",
"$",
"this",
"->",
"current",
";... | Return an array with tables and fields related to the searched foreign key.
```php
bbn\x::dump($db->get_foreign_keys('id', 'table_users', 'db_example'));
// (Array)
```
@param string $col The column's name
@param string $table The table's name
@param string $db The database name if different from the current one
@ret... | [
"Return",
"an",
"array",
"with",
"tables",
"and",
"fields",
"related",
"to",
"the",
"searched",
"foreign",
"key",
"."
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/db.php#L1735-L1759 |
nabab/bbn | src/bbn/db.php | db.has_id_increment | public function has_id_increment($table): bool
{
return ($model = $this->modelize($table)) &&
isset($model['keys']['PRIMARY']) &&
(\count($model['keys']['PRIMARY']['columns']) === 1) &&
($model['fields'][$model['keys']['PRIMARY']['columns'][0]]['extra'] === 'auto_increment');
} | php | public function has_id_increment($table): bool
{
return ($model = $this->modelize($table)) &&
isset($model['keys']['PRIMARY']) &&
(\count($model['keys']['PRIMARY']['columns']) === 1) &&
($model['fields'][$model['keys']['PRIMARY']['columns'][0]]['extra'] === 'auto_increment');
} | [
"public",
"function",
"has_id_increment",
"(",
"$",
"table",
")",
":",
"bool",
"{",
"return",
"(",
"$",
"model",
"=",
"$",
"this",
"->",
"modelize",
"(",
"$",
"table",
")",
")",
"&&",
"isset",
"(",
"$",
"model",
"[",
"'keys'",
"]",
"[",
"'PRIMARY'",
... | Return true if in the table there are fields with auto-increment.
Working only on mysql.
```php
\bbn\x::dump($db->has_id_increment('table_users'));
// (bool) 1
```
@param string $table The table's name
@return bool | [
"Return",
"true",
"if",
"in",
"the",
"table",
"there",
"are",
"fields",
"with",
"auto",
"-",
"increment",
".",
"Working",
"only",
"on",
"mysql",
"."
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/db.php#L1773-L1779 |
nabab/bbn | src/bbn/db.php | db.modelize | public function modelize($table = null, bool $force = false): ?array
{
$r = [];
$tables = false;
if ( empty($table) || $table === '*' ){
$tables = $this->get_tables($this->current);
}
else if ( \is_string($table) ){
$tables = [$table];
}
else if ( \is_array($table) ){
$ta... | php | public function modelize($table = null, bool $force = false): ?array
{
$r = [];
$tables = false;
if ( empty($table) || $table === '*' ){
$tables = $this->get_tables($this->current);
}
else if ( \is_string($table) ){
$tables = [$table];
}
else if ( \is_array($table) ){
$ta... | [
"public",
"function",
"modelize",
"(",
"$",
"table",
"=",
"null",
",",
"bool",
"$",
"force",
"=",
"false",
")",
":",
"?",
"array",
"{",
"$",
"r",
"=",
"[",
"]",
";",
"$",
"tables",
"=",
"false",
";",
"if",
"(",
"empty",
"(",
"$",
"table",
")",
... | Return the table's structure as an indexed array.
```php
\bbn\x::dump($db->modelize("table_users"));
// (array) [keys] => Array ( [PRIMARY] => Array ( [columns] => Array ( [0] => userid [1] => userdataid ) [ref_db] => [ref_table] => [ref_column] => [unique] => 1 ) [table_users_userId_userdataId_info] => Array ( [c... | [
"Return",
"the",
"table",
"s",
"structure",
"as",
"an",
"indexed",
"array",
"."
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/db.php#L1793-L1817 |
nabab/bbn | src/bbn/db.php | db.find_references | public function find_references($column, $db = ''): array
{
$changed = false;
if ( $db && ($db !== $this->current) ){
$changed = $this->current;
$this->change($db);
}
$column = $this->cfn($column);
$bits = explode('.', $column);
if ( \count($bits) === 2 ){
array_unshift($bits... | php | public function find_references($column, $db = ''): array
{
$changed = false;
if ( $db && ($db !== $this->current) ){
$changed = $this->current;
$this->change($db);
}
$column = $this->cfn($column);
$bits = explode('.', $column);
if ( \count($bits) === 2 ){
array_unshift($bits... | [
"public",
"function",
"find_references",
"(",
"$",
"column",
",",
"$",
"db",
"=",
"''",
")",
":",
"array",
"{",
"$",
"changed",
"=",
"false",
";",
"if",
"(",
"$",
"db",
"&&",
"(",
"$",
"db",
"!==",
"$",
"this",
"->",
"current",
")",
")",
"{",
"... | find_references
@param $column
@param string $db
@return array|bool | [
"find_references"
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/db.php#L1849-L1881 |
nabab/bbn | src/bbn/db.php | db.find_relations | public function find_relations($column, $db = ''): ?array
{
$changed = false;
if ( $db && ($db !== $this->current) ){
$changed = $this->current;
$this->change($db);
}
$column = $this->cfn($column);
$bits = explode('.', $column);
if ( \count($bits) === 2 ){
array_unshift($bits... | php | public function find_relations($column, $db = ''): ?array
{
$changed = false;
if ( $db && ($db !== $this->current) ){
$changed = $this->current;
$this->change($db);
}
$column = $this->cfn($column);
$bits = explode('.', $column);
if ( \count($bits) === 2 ){
array_unshift($bits... | [
"public",
"function",
"find_relations",
"(",
"$",
"column",
",",
"$",
"db",
"=",
"''",
")",
":",
"?",
"array",
"{",
"$",
"changed",
"=",
"false",
";",
"if",
"(",
"$",
"db",
"&&",
"(",
"$",
"db",
"!==",
"$",
"this",
"->",
"current",
")",
")",
"{... | find_relations
@param $column
@param string $db
@return array|bool | [
"find_relations"
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/db.php#L1890-L1948 |
nabab/bbn | src/bbn/db.php | db.get_unique_primary | public function get_unique_primary($table): ?string
{
if ( ($keys = $this->get_keys($table)) &&
isset($keys['keys']['PRIMARY']) &&
(\count($keys['keys']['PRIMARY']['columns']) === 1) ){
return $keys['keys']['PRIMARY']['columns'][0];
}
return null;
} | php | public function get_unique_primary($table): ?string
{
if ( ($keys = $this->get_keys($table)) &&
isset($keys['keys']['PRIMARY']) &&
(\count($keys['keys']['PRIMARY']['columns']) === 1) ){
return $keys['keys']['PRIMARY']['columns'][0];
}
return null;
} | [
"public",
"function",
"get_unique_primary",
"(",
"$",
"table",
")",
":",
"?",
"string",
"{",
"if",
"(",
"(",
"$",
"keys",
"=",
"$",
"this",
"->",
"get_keys",
"(",
"$",
"table",
")",
")",
"&&",
"isset",
"(",
"$",
"keys",
"[",
"'keys'",
"]",
"[",
"... | Return the unique primary key of the given table.
```php
\bbn\x::dump($db->get_unique_primary('table_users'));
// (string) id
```
@param string $table The table's name
@return null|string | [
"Return",
"the",
"unique",
"primary",
"key",
"of",
"the",
"given",
"table",
"."
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/db.php#L1980-L1988 |
nabab/bbn | src/bbn/db.php | db.get_unique_keys | public function get_unique_keys($table): array
{
$fields = [[]];
if ( $ks = $this->get_keys($table) ){
foreach ( $ks['keys'] as $k ){
if ( $k['unique'] ){
$fields[] = $k['columns'];
}
}
}
return array_merge(...$fields);
} | php | public function get_unique_keys($table): array
{
$fields = [[]];
if ( $ks = $this->get_keys($table) ){
foreach ( $ks['keys'] as $k ){
if ( $k['unique'] ){
$fields[] = $k['columns'];
}
}
}
return array_merge(...$fields);
} | [
"public",
"function",
"get_unique_keys",
"(",
"$",
"table",
")",
":",
"array",
"{",
"$",
"fields",
"=",
"[",
"[",
"]",
"]",
";",
"if",
"(",
"$",
"ks",
"=",
"$",
"this",
"->",
"get_keys",
"(",
"$",
"table",
")",
")",
"{",
"foreach",
"(",
"$",
"k... | Return the unique keys of a table as a numeric array.
```php
\bbn\x::dump($db->get_unique_keys('table_users'));
// (array) ["userid", "userdataid"]
```
@param string $table The table's name
@return array | [
"Return",
"the",
"unique",
"keys",
"of",
"a",
"table",
"as",
"a",
"numeric",
"array",
"."
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/db.php#L2001-L2012 |
nabab/bbn | src/bbn/db.php | db.escape_value | public function escape_value(string $value, $esc = "'"): string
{
return str_replace('%', '\\%', $esc === '"' ?
str::escape_dquotes($value) :
str::escape_squotes($value));
} | php | public function escape_value(string $value, $esc = "'"): string
{
return str_replace('%', '\\%', $esc === '"' ?
str::escape_dquotes($value) :
str::escape_squotes($value));
} | [
"public",
"function",
"escape_value",
"(",
"string",
"$",
"value",
",",
"$",
"esc",
"=",
"\"'\"",
")",
":",
"string",
"{",
"return",
"str_replace",
"(",
"'%'",
",",
"'\\\\%'",
",",
"$",
"esc",
"===",
"'\"'",
"?",
"str",
"::",
"escape_dquotes",
"(",
"$"... | Return a string with quotes and percent escaped.
```php
bbn\x::dump($db->escape_value("My father's job is interesting");
// (string) My father\'s job is interesting
```
@param string $value The string to escape.
@param string $esc
@return string | [
"Return",
"a",
"string",
"with",
"quotes",
"and",
"percent",
"escaped",
"."
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/db.php#L2035-L2040 |
nabab/bbn | src/bbn/db.php | db.set_last_insert_id | public function set_last_insert_id($id=''): self
{
if ( $id === '' ){
if ( $this->id_just_inserted ){
$id = $this->id_just_inserted;
$this->id_just_inserted = null;
}
else{
$id = $this->lastInsertId();
if ( \is_string($id) && str::is_integer($id) ){
$id ... | php | public function set_last_insert_id($id=''): self
{
if ( $id === '' ){
if ( $this->id_just_inserted ){
$id = $this->id_just_inserted;
$this->id_just_inserted = null;
}
else{
$id = $this->lastInsertId();
if ( \is_string($id) && str::is_integer($id) ){
$id ... | [
"public",
"function",
"set_last_insert_id",
"(",
"$",
"id",
"=",
"''",
")",
":",
"self",
"{",
"if",
"(",
"$",
"id",
"===",
"''",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"id_just_inserted",
")",
"{",
"$",
"id",
"=",
"$",
"this",
"->",
"id_just_inser... | Changes the value of last_insert_id (used by history).
@todo this function should be private
```php
bbn\x::dump($db->set_last_insert_id());
// (db)
```
@param mixed $id The last inserted id
@return self | [
"Changes",
"the",
"value",
"of",
"last_insert_id",
"(",
"used",
"by",
"history",
")",
".",
"@todo",
"this",
"function",
"should",
"be",
"private"
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/db.php#L2053-L2072 |
nabab/bbn | src/bbn/db.php | db.parse_query | public function parse_query(string $statement): ?array
{
if ( $this->parser === null ){
$this->parser = new \PHPSQLParser\PHPSQLParser();
}
try {
$r = $this->parser->parse($statement);
if ( !count($r) ){
return null;
}
if ( isset($r['BRACKET']) && (\count($r) === 1) )... | php | public function parse_query(string $statement): ?array
{
if ( $this->parser === null ){
$this->parser = new \PHPSQLParser\PHPSQLParser();
}
try {
$r = $this->parser->parse($statement);
if ( !count($r) ){
return null;
}
if ( isset($r['BRACKET']) && (\count($r) === 1) )... | [
"public",
"function",
"parse_query",
"(",
"string",
"$",
"statement",
")",
":",
"?",
"array",
"{",
"if",
"(",
"$",
"this",
"->",
"parser",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"parser",
"=",
"new",
"\\",
"PHPSQLParser",
"\\",
"PHPSQLParser",
"("... | Parses a SQL query and return an array.
@param string $statement
@return null|array | [
"Parses",
"a",
"SQL",
"query",
"and",
"return",
"an",
"array",
"."
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/db.php#L2080-L2099 |
nabab/bbn | src/bbn/db.php | db.last_id | public function last_id()
{
if ( $this->last_insert_id ){
return str::is_buid($this->last_insert_id) ? bin2hex($this->last_insert_id) : $this->last_insert_id;
}
return false;
} | php | public function last_id()
{
if ( $this->last_insert_id ){
return str::is_buid($this->last_insert_id) ? bin2hex($this->last_insert_id) : $this->last_insert_id;
}
return false;
} | [
"public",
"function",
"last_id",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"last_insert_id",
")",
"{",
"return",
"str",
"::",
"is_buid",
"(",
"$",
"this",
"->",
"last_insert_id",
")",
"?",
"bin2hex",
"(",
"$",
"this",
"->",
"last_insert_id",
")",
":... | Return the last inserted ID.
```php
\bbn\x::dump($db->last_id());
// (int) 26
```
@return mixed | [
"Return",
"the",
"last",
"inserted",
"ID",
"."
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/db.php#L2126-L2132 |
nabab/bbn | src/bbn/db.php | db.new_id | public function new_id($table, int $min = 1){
$tab = $this->modelize($table);
if ( \count($tab['keys']['PRIMARY']['columns']) !== 1 ){
die("Error! Unique numeric primary key doesn't exist");
}
if (
($id_field = $tab['keys']['PRIMARY']['columns'][0]) &&
($maxlength = $tab['fields'][$id_... | php | public function new_id($table, int $min = 1){
$tab = $this->modelize($table);
if ( \count($tab['keys']['PRIMARY']['columns']) !== 1 ){
die("Error! Unique numeric primary key doesn't exist");
}
if (
($id_field = $tab['keys']['PRIMARY']['columns'][0]) &&
($maxlength = $tab['fields'][$id_... | [
"public",
"function",
"new_id",
"(",
"$",
"table",
",",
"int",
"$",
"min",
"=",
"1",
")",
"{",
"$",
"tab",
"=",
"$",
"this",
"->",
"modelize",
"(",
"$",
"table",
")",
";",
"if",
"(",
"\\",
"count",
"(",
"$",
"tab",
"[",
"'keys'",
"]",
"[",
"'... | Generate a new casual id based on the max number of characters of id's column structure in the given table
```php
\bbn\x::dump($db->new_id('table_users', 18));
// (int) 69991701
```
@todo Either get rid of th efunction or include the UID types
@param null|string $table The table's name.
@param int $min
@return mixed | [
"Generate",
"a",
"new",
"casual",
"id",
"based",
"on",
"the",
"max",
"number",
"of",
"characters",
"of",
"id",
"s",
"column",
"structure",
"in",
"the",
"given",
"table"
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/db.php#L2173-L2204 |
nabab/bbn | src/bbn/db.php | db.random_value | public function random_value($col, $table){
$val = null;
if ( ($tab = $this->modelize($table)) && isset($tab['fields'][$col]) ){
foreach ( $tab['keys'] as $key => $cfg ){
if (
$cfg['unique'] &&
!empty($cfg['ref_column']) &&
(\count($cfg['columns']) === 1) &&
... | php | public function random_value($col, $table){
$val = null;
if ( ($tab = $this->modelize($table)) && isset($tab['fields'][$col]) ){
foreach ( $tab['keys'] as $key => $cfg ){
if (
$cfg['unique'] &&
!empty($cfg['ref_column']) &&
(\count($cfg['columns']) === 1) &&
... | [
"public",
"function",
"random_value",
"(",
"$",
"col",
",",
"$",
"table",
")",
"{",
"$",
"val",
"=",
"null",
";",
"if",
"(",
"(",
"$",
"tab",
"=",
"$",
"this",
"->",
"modelize",
"(",
"$",
"table",
")",
")",
"&&",
"isset",
"(",
"$",
"tab",
"[",
... | Returns a random value fitting the requested column's type
@todo This great function has to be done properly
@param $col
@param $table
@return mixed | [
"Returns",
"a",
"random",
"value",
"fitting",
"the",
"requested",
"column",
"s",
"type"
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/db.php#L2214-L2277 |
nabab/bbn | src/bbn/db.php | db.get_key_val | public function get_key_val(): ?array
{
if ( $r = $this->query(...\func_get_args()) ){
if ( $rows = $r->get_rows() ){
return x::index_by_first_val($rows);
}
return [];
}
return null;
} | php | public function get_key_val(): ?array
{
if ( $r = $this->query(...\func_get_args()) ){
if ( $rows = $r->get_rows() ){
return x::index_by_first_val($rows);
}
return [];
}
return null;
} | [
"public",
"function",
"get_key_val",
"(",
")",
":",
"?",
"array",
"{",
"if",
"(",
"$",
"r",
"=",
"$",
"this",
"->",
"query",
"(",
"...",
"\\",
"func_get_args",
"(",
")",
")",
")",
"{",
"if",
"(",
"$",
"rows",
"=",
"$",
"r",
"->",
"get_rows",
"(... | Return an array indexed on the first field of the request.
The value will be an array if the request has more than two fields.
```php
\bbn\x::dump($db->get_key_val("SELECT name,id_group FROM table_users"));
/*
(array)[
"John" => 1,
"Michael" => 1,
"Barbara" => 1
]
\bbn\x::dump($db->get_key_val("SELECT name, surname, ... | [
"Return",
"an",
"array",
"indexed",
"on",
"the",
"first",
"field",
"of",
"the",
"request",
".",
"The",
"value",
"will",
"be",
"an",
"array",
"if",
"the",
"request",
"has",
"more",
"than",
"two",
"fields",
"."
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/db.php#L2363-L2372 |
nabab/bbn | src/bbn/db.php | db.select | public function select($table, $fields = [], array $where = [], array $order = [], int $start = 0): ?\stdClass
{
$args = $this->_add_kind($this->_set_limit_1(\func_get_args()));
if ( $r = $this->_exec(...$args) ){
return $r->get_object();
}
return null;
} | php | public function select($table, $fields = [], array $where = [], array $order = [], int $start = 0): ?\stdClass
{
$args = $this->_add_kind($this->_set_limit_1(\func_get_args()));
if ( $r = $this->_exec(...$args) ){
return $r->get_object();
}
return null;
} | [
"public",
"function",
"select",
"(",
"$",
"table",
",",
"$",
"fields",
"=",
"[",
"]",
",",
"array",
"$",
"where",
"=",
"[",
"]",
",",
"array",
"$",
"order",
"=",
"[",
"]",
",",
"int",
"$",
"start",
"=",
"0",
")",
":",
"?",
"\\",
"stdClass",
"... | Returns the first row resulting from the query as an object.
```php
\bbn\x::dump($db->select('table_users', ['name', 'surname'], [['id','>','2']]));
/*
(object){
"name": "John",
"surname": "Smith",
}
```
@param string|array $table The table's name or a configuration array
@param string|array $fields The fields' name
... | [
"Returns",
"the",
"first",
"row",
"resulting",
"from",
"the",
"query",
"as",
"an",
"object",
"."
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/db.php#L2422-L2429 |
nabab/bbn | src/bbn/db.php | db.select_all | public function select_all($table, $fields = [], array $where = [], array $order = [], int $limit = 0, int $start = 0): ?array
{
if ( $r = $this->_exec(...$this->_add_kind(\func_get_args())) ){
return $r->get_objects();
}
return null;
} | php | public function select_all($table, $fields = [], array $where = [], array $order = [], int $limit = 0, int $start = 0): ?array
{
if ( $r = $this->_exec(...$this->_add_kind(\func_get_args())) ){
return $r->get_objects();
}
return null;
} | [
"public",
"function",
"select_all",
"(",
"$",
"table",
",",
"$",
"fields",
"=",
"[",
"]",
",",
"array",
"$",
"where",
"=",
"[",
"]",
",",
"array",
"$",
"order",
"=",
"[",
"]",
",",
"int",
"$",
"limit",
"=",
"0",
",",
"int",
"$",
"start",
"=",
... | Return table's rows resulting from the query as an array of objects.
```php
\bbn\x::dump($db->select_all("tab_users", ["id", "name", "surname"],[["id", ">", 1]], ["id" => "ASC"], 2));
/*
(array)[
Object stdClass: df {
"id" => 2,
"name" => "John",
"surname" => "Smith",
},
Object stdClass: df {
"id" => 3,
"name" => "Tho... | [
"Return",
"table",
"s",
"rows",
"resulting",
"from",
"the",
"query",
"as",
"an",
"array",
"of",
"objects",
"."
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/db.php#L2459-L2465 |
nabab/bbn | src/bbn/db.php | db.iselect | public function iselect($table, $fields = [], array $where = [], array $order = [], int $start = 0): ?array
{
if ( $r = $this->_exec(...$this->_add_kind($this->_set_limit_1(\func_get_args()))) ){
return $r->get_irow();
}
return null;
} | php | public function iselect($table, $fields = [], array $where = [], array $order = [], int $start = 0): ?array
{
if ( $r = $this->_exec(...$this->_add_kind($this->_set_limit_1(\func_get_args()))) ){
return $r->get_irow();
}
return null;
} | [
"public",
"function",
"iselect",
"(",
"$",
"table",
",",
"$",
"fields",
"=",
"[",
"]",
",",
"array",
"$",
"where",
"=",
"[",
"]",
",",
"array",
"$",
"order",
"=",
"[",
"]",
",",
"int",
"$",
"start",
"=",
"0",
")",
":",
"?",
"array",
"{",
"if"... | Return the first row resulting from the query as a numeric array.
```php
\bbn\x::dump($db->iselect("tab_users", ["id", "name", "surname"], [["id", ">", 1]], ["id" => "ASC"], 2));
/*
(array)[
4,
"Jack",
"Stewart"
]
```
@param string|array $table The table's name or a configuration array
@param string|array $fields The... | [
"Return",
"the",
"first",
"row",
"resulting",
"from",
"the",
"query",
"as",
"a",
"numeric",
"array",
"."
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/db.php#L2487-L2493 |
nabab/bbn | src/bbn/db.php | db.iselect_all | public function iselect_all($table, $fields = [], array $where = [], array $order = [], int $limit = 0, int $start = 0): ?array
{
if ( $r = $this->_exec(...$this->_add_kind(\func_get_args())) ){
return $r->get_irows();
}
return null;
} | php | public function iselect_all($table, $fields = [], array $where = [], array $order = [], int $limit = 0, int $start = 0): ?array
{
if ( $r = $this->_exec(...$this->_add_kind(\func_get_args())) ){
return $r->get_irows();
}
return null;
} | [
"public",
"function",
"iselect_all",
"(",
"$",
"table",
",",
"$",
"fields",
"=",
"[",
"]",
",",
"array",
"$",
"where",
"=",
"[",
"]",
",",
"array",
"$",
"order",
"=",
"[",
"]",
",",
"int",
"$",
"limit",
"=",
"0",
",",
"int",
"$",
"start",
"=",
... | Return the searched rows as an array of numeric arrays.
```php
\bbn\x::dump($db->iselect_all("tab_users", ["id", "name", "surname"], [["id", ">", 1]],["id" => "ASC"],2));
/*
(array)[
[
2,
"John",
"Smith",
],
[
3,
"Thomas",
"Jones",
]
]
```
@param string|array $table The table's name or a configuration array
@param st... | [
"Return",
"the",
"searched",
"rows",
"as",
"an",
"array",
"of",
"numeric",
"arrays",
"."
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/db.php#L2523-L2529 |
nabab/bbn | src/bbn/db.php | db.rselect | public function rselect($table, $fields = [], array $where = [], array $order = [], int $start = 0): ?array
{
if ( $r = $this->_exec(...$this->_add_kind($this->_set_limit_1(\func_get_args()))) ){
return $r->get_row();
}
return null;
} | php | public function rselect($table, $fields = [], array $where = [], array $order = [], int $start = 0): ?array
{
if ( $r = $this->_exec(...$this->_add_kind($this->_set_limit_1(\func_get_args()))) ){
return $r->get_row();
}
return null;
} | [
"public",
"function",
"rselect",
"(",
"$",
"table",
",",
"$",
"fields",
"=",
"[",
"]",
",",
"array",
"$",
"where",
"=",
"[",
"]",
",",
"array",
"$",
"order",
"=",
"[",
"]",
",",
"int",
"$",
"start",
"=",
"0",
")",
":",
"?",
"array",
"{",
"if"... | Return the first row resulting from the query as an indexed array.
```php
\bbn\x::dump($db->rselect("tab_users", ["id", "name", "surname"], ["id", ">", 1], ["id" => "ASC"], 2));
/*
(array) [
"id" => 4,
"name" => "John",
"surname" => "Smith"
]
```
@param string|array $table The table's name or a configuration array
@p... | [
"Return",
"the",
"first",
"row",
"resulting",
"from",
"the",
"query",
"as",
"an",
"indexed",
"array",
"."
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/db.php#L2551-L2557 |
nabab/bbn | src/bbn/db.php | db.rselect_all | public function rselect_all($table, $fields = [], array $where = [], array $order = [], $limit = 0, $start = 0): ?array
{
if ( $r = $this->_exec(...$this->_add_kind(\func_get_args())) ){
if ( \is_object($r) ){
return $r->get_rows();
}
$this->log('ERROR IN RSELECT_ALL', $r);
}
ret... | php | public function rselect_all($table, $fields = [], array $where = [], array $order = [], $limit = 0, $start = 0): ?array
{
if ( $r = $this->_exec(...$this->_add_kind(\func_get_args())) ){
if ( \is_object($r) ){
return $r->get_rows();
}
$this->log('ERROR IN RSELECT_ALL', $r);
}
ret... | [
"public",
"function",
"rselect_all",
"(",
"$",
"table",
",",
"$",
"fields",
"=",
"[",
"]",
",",
"array",
"$",
"where",
"=",
"[",
"]",
",",
"array",
"$",
"order",
"=",
"[",
"]",
",",
"$",
"limit",
"=",
"0",
",",
"$",
"start",
"=",
"0",
")",
":... | Return table's rows as an array of indexed arrays.
```php
\bbn\x::dump($db->rselect_all("tab_users", ["id", "name", "surname"], [["id", ">", 1]], ["id" => "ASC"], 2));
/*
(array) [
[
"id" => 2,
"name" => "John",
"surname" => "Smith",
],
[
"id" => 3,
"name" => "Thomas",
"surname" => "Jones",
]
]
```
@param string|arra... | [
"Return",
"table",
"s",
"rows",
"as",
"an",
"array",
"of",
"indexed",
"arrays",
"."
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/db.php#L2587-L2596 |
nabab/bbn | src/bbn/db.php | db.select_one | public function select_one($table, $field = null, array $where = [], array $order = [], int $start = 0)
{
if ( $r = $this->_exec(...$this->_add_kind($this->_set_limit_1(\func_get_args()))) ){
if ( \is_object($r) ){
return ($a = $r->get_irow()) ? $a[0] : false;
}
$this->log('ERROR IN RSEL... | php | public function select_one($table, $field = null, array $where = [], array $order = [], int $start = 0)
{
if ( $r = $this->_exec(...$this->_add_kind($this->_set_limit_1(\func_get_args()))) ){
if ( \is_object($r) ){
return ($a = $r->get_irow()) ? $a[0] : false;
}
$this->log('ERROR IN RSEL... | [
"public",
"function",
"select_one",
"(",
"$",
"table",
",",
"$",
"field",
"=",
"null",
",",
"array",
"$",
"where",
"=",
"[",
"]",
",",
"array",
"$",
"order",
"=",
"[",
"]",
",",
"int",
"$",
"start",
"=",
"0",
")",
"{",
"if",
"(",
"$",
"r",
"=... | Return a single value
```php
\bbn\x::dump($db->select_one("tab_users", "name", [["id", ">", 1]], ["id" => "DESC"], 2));
(string) 'Michael'
```
@param string|array $table The table's name or a configuration array
@param string $field The field's name
@param array $where The "where" condition
@param array | boolean $o... | [
"Return",
"a",
"single",
"value"
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/db.php#L2613-L2622 |
nabab/bbn | src/bbn/db.php | db.count | public function count($table, array $where = []): ?int
{
$args = \is_array($table) && isset($table['tables']) ? $table : [
'tables' => [$table],
'where' => $where
];
$args['count'] = true;
if ( !empty($args['bbn_db_processed']) ){
unset($args['bbn_db_processed']);
}
if ( \is_... | php | public function count($table, array $where = []): ?int
{
$args = \is_array($table) && isset($table['tables']) ? $table : [
'tables' => [$table],
'where' => $where
];
$args['count'] = true;
if ( !empty($args['bbn_db_processed']) ){
unset($args['bbn_db_processed']);
}
if ( \is_... | [
"public",
"function",
"count",
"(",
"$",
"table",
",",
"array",
"$",
"where",
"=",
"[",
"]",
")",
":",
"?",
"int",
"{",
"$",
"args",
"=",
"\\",
"is_array",
"(",
"$",
"table",
")",
"&&",
"isset",
"(",
"$",
"table",
"[",
"'tables'",
"]",
")",
"?"... | Return the number of records in the table corresponding to the $where condition (non mandatory).
```php
\bbn\x::dump($db->count('table_users', ['name' => 'John']));
// (int) 2
```
@param string|array $table The table's name or a configuration array
@param array $where The "where" condition
@return int | [
"Return",
"the",
"number",
"of",
"records",
"in",
"the",
"table",
"corresponding",
"to",
"the",
"$where",
"condition",
"(",
"non",
"mandatory",
")",
"."
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/db.php#L2636-L2651 |
nabab/bbn | src/bbn/db.php | db.select_all_by_keys | public function select_all_by_keys($table, array $fields = [], array $where = [], array $order = [], int $limit = 0, int $start = 0): ?array
{
if ( $rows = $this->rselect_all($table, $fields, $where, $order, $limit, $start) ){
return x::index_by_first_val($rows);
}
return $this->check() ? [] : null;... | php | public function select_all_by_keys($table, array $fields = [], array $where = [], array $order = [], int $limit = 0, int $start = 0): ?array
{
if ( $rows = $this->rselect_all($table, $fields, $where, $order, $limit, $start) ){
return x::index_by_first_val($rows);
}
return $this->check() ? [] : null;... | [
"public",
"function",
"select_all_by_keys",
"(",
"$",
"table",
",",
"array",
"$",
"fields",
"=",
"[",
"]",
",",
"array",
"$",
"where",
"=",
"[",
"]",
",",
"array",
"$",
"order",
"=",
"[",
"]",
",",
"int",
"$",
"limit",
"=",
"0",
",",
"int",
"$",
... | Return an array indexed on the first field of the request.
The value will be an array if the request has more than two fields.
Return the same value as "get_key_val".
```php
\bbn\x::dump($db->select_all_by_keys("table_users", ["name","id","surname"], [["id", ">", "1"]], ["id" => "ASC"]);
/*
(array)[
"John" => [
"surna... | [
"Return",
"an",
"array",
"indexed",
"on",
"the",
"first",
"field",
"of",
"the",
"request",
".",
"The",
"value",
"will",
"be",
"an",
"array",
"if",
"the",
"request",
"has",
"more",
"than",
"two",
"fields",
".",
"Return",
"the",
"same",
"value",
"as",
"g... | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/db.php#L2681-L2687 |
nabab/bbn | src/bbn/db.php | db.stat | public function stat(string $table, string $column, array $where = [], array $order = []): ?array{
if ( $this->check() ){
return $this->rselect_all([
'tables' => [$table],
'fields' => [
$column,
'num' => 'COUNT(*)'
],
'where' => $where,
'order' => $o... | php | public function stat(string $table, string $column, array $where = [], array $order = []): ?array{
if ( $this->check() ){
return $this->rselect_all([
'tables' => [$table],
'fields' => [
$column,
'num' => 'COUNT(*)'
],
'where' => $where,
'order' => $o... | [
"public",
"function",
"stat",
"(",
"string",
"$",
"table",
",",
"string",
"$",
"column",
",",
"array",
"$",
"where",
"=",
"[",
"]",
",",
"array",
"$",
"order",
"=",
"[",
"]",
")",
":",
"?",
"array",
"{",
"if",
"(",
"$",
"this",
"->",
"check",
"... | Return an array with the count of values corresponding to the where conditions.
```php
\bbn\x::dump($db->stat('table_user', 'name', ['name' => '%n']));
/* (array)
[
[
"num" => 1,
"name" => "alan",
], [
"num" => 1,
"name" => "karen",
],
]
```
@param string|array $table The table's name or a configuration array.
@param... | [
"Return",
"an",
"array",
"with",
"the",
"count",
"of",
"values",
"corresponding",
"to",
"the",
"where",
"conditions",
"."
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/db.php#L2712-L2726 |
nabab/bbn | src/bbn/db.php | db.get_field_values | public function get_field_values($table, $field = null, array $where = [], array $order = []){
return $this->get_column_values($table, $field, $where, $order);
} | php | public function get_field_values($table, $field = null, array $where = [], array $order = []){
return $this->get_column_values($table, $field, $where, $order);
} | [
"public",
"function",
"get_field_values",
"(",
"$",
"table",
",",
"$",
"field",
"=",
"null",
",",
"array",
"$",
"where",
"=",
"[",
"]",
",",
"array",
"$",
"order",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"get_column_values",
"(",
"$",
... | Return the unique values of a column of a table as a numeric indexed array.
```php
\bbn\x::dump($db->get_field_values("table_users", "surname", [['id', '>', '2']], 1, 1));
// (array) ["Smiths", "White"]
```
@param string|array $table The table's name or a configuration array
@param string $field The field's name
@par... | [
"Return",
"the",
"unique",
"values",
"of",
"a",
"column",
"of",
"a",
"table",
"as",
"a",
"numeric",
"indexed",
"array",
"."
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/db.php#L2742-L2744 |
nabab/bbn | src/bbn/db.php | db.count_field_values | public function count_field_values($table, string $field = null, array $where = [], array $order = []){
if ( \is_array($table) && \is_array($table['fields']) && count($table['fields']) ){
$args = $table;
$field = array_values($table['fields'])[0];
}
else{
$args = [
'tables' => [$t... | php | public function count_field_values($table, string $field = null, array $where = [], array $order = []){
if ( \is_array($table) && \is_array($table['fields']) && count($table['fields']) ){
$args = $table;
$field = array_values($table['fields'])[0];
}
else{
$args = [
'tables' => [$t... | [
"public",
"function",
"count_field_values",
"(",
"$",
"table",
",",
"string",
"$",
"field",
"=",
"null",
",",
"array",
"$",
"where",
"=",
"[",
"]",
",",
"array",
"$",
"order",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"\\",
"is_array",
"(",
"$",
"table",... | Return a count of identical values in a field as array, reporting a structure type 'num' - 'val'.
```php
\bbn\x::dump($db->count_field_values('table_users','surname',[['name','=','John']]));
// (array) ["num" => 2, "val" => "John"]
```
@param string|array $table The table's name or a configuration array
@param null|s... | [
"Return",
"a",
"count",
"of",
"identical",
"values",
"in",
"a",
"field",
"as",
"array",
"reporting",
"a",
"structure",
"type",
"num",
"-",
"val",
"."
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/db.php#L2760-L2781 |
nabab/bbn | src/bbn/db.php | db.get_column_values | public function get_column_values($table, string $field = null, array $where = [], array $order = []): ?array
{
if ( \is_array($table) && isset($table['fields']) && \is_array($table['fields']) && !empty($table['fields'][0]) ){
array_splice($table['fields'], 0, 1, 'DISTINCT '.(string)$table['fields'][0]);
... | php | public function get_column_values($table, string $field = null, array $where = [], array $order = []): ?array
{
if ( \is_array($table) && isset($table['fields']) && \is_array($table['fields']) && !empty($table['fields'][0]) ){
array_splice($table['fields'], 0, 1, 'DISTINCT '.(string)$table['fields'][0]);
... | [
"public",
"function",
"get_column_values",
"(",
"$",
"table",
",",
"string",
"$",
"field",
"=",
"null",
",",
"array",
"$",
"where",
"=",
"[",
"]",
",",
"array",
"$",
"order",
"=",
"[",
"]",
")",
":",
"?",
"array",
"{",
"if",
"(",
"\\",
"is_array",
... | Return a numeric indexed array with the values of the unique column ($field) from the selected $table
```php
\bbn\x::dump($db->get_column_values('table_users','surname',['id','>',1]));
/*
array [
"Smith",
"Jones",
"Williams",
"Taylor"
]
```
@param string|array $table The table's name or a configuration array
@param s... | [
"Return",
"a",
"numeric",
"indexed",
"array",
"with",
"the",
"values",
"of",
"the",
"unique",
"column",
"(",
"$field",
")",
"from",
"the",
"selected",
"$table"
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/db.php#L2803-L2819 |
nabab/bbn | src/bbn/db.php | db.get_values_count | public function get_values_count($table, string $field = null, array $where = [], $order): array
{
return $this->count_field_values($table, $field, $where, $order);
} | php | public function get_values_count($table, string $field = null, array $where = [], $order): array
{
return $this->count_field_values($table, $field, $where, $order);
} | [
"public",
"function",
"get_values_count",
"(",
"$",
"table",
",",
"string",
"$",
"field",
"=",
"null",
",",
"array",
"$",
"where",
"=",
"[",
"]",
",",
"$",
"order",
")",
":",
"array",
"{",
"return",
"$",
"this",
"->",
"count_field_values",
"(",
"$",
... | Return a string with the sql query to count equal values in a field of the table.
```php
\bbn\x::dump($db->get_values_count('table_users','name',['surname','=','smith']));
/*
(string)
SELECT COUNT(*) AS num, `name` AS val FROM `db_example`.`table_users`
GROUP BY `name`
ORDER BY `name`
```
@param string|array $table T... | [
"Return",
"a",
"string",
"with",
"the",
"sql",
"query",
"to",
"count",
"equal",
"values",
"in",
"a",
"field",
"of",
"the",
"table",
"."
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/db.php#L2839-L2842 |
nabab/bbn | src/bbn/db.php | db.insert | public function insert($table, array $values = null, $ignore = false): ?int
{
if ( \is_array($table) && isset($table['values']) ){
$values = $table['values'];
}
// Array of arrays
if (
\is_array($values) &&
count($values) &&
!x::is_assoc($values) &&
\is_array($values[0])
... | php | public function insert($table, array $values = null, $ignore = false): ?int
{
if ( \is_array($table) && isset($table['values']) ){
$values = $table['values'];
}
// Array of arrays
if (
\is_array($values) &&
count($values) &&
!x::is_assoc($values) &&
\is_array($values[0])
... | [
"public",
"function",
"insert",
"(",
"$",
"table",
",",
"array",
"$",
"values",
"=",
"null",
",",
"$",
"ignore",
"=",
"false",
")",
":",
"?",
"int",
"{",
"if",
"(",
"\\",
"is_array",
"(",
"$",
"table",
")",
"&&",
"isset",
"(",
"$",
"table",
"[",
... | Inserts row(s) in a table.
<code>
$this->db->insert("table_users", [
["name" => "Ted"],
["surname" => "McLow"]
]);
</code>
<code>
$this->db->insert("table_users", [
["name" => "July"],
["surname" => "O'neill"]
], [
["name" => "Peter"],
["surname" => "Griffin"]
], [
["name" => "Marge"],
["surname" => "Simpson"]
]);
</... | [
"Inserts",
"row",
"(",
"s",
")",
"in",
"a",
"table",
"."
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/db.php#L2881-L2908 |
nabab/bbn | src/bbn/db.php | db.insert_update | public function insert_update($table, array $values = null): ?int {
// Twice the arguments
if ( \is_array($table) && isset($table['values']) ){
$values = $table['values'];
}
if ( !x::is_assoc($values) ){
$res = 0;
foreach ( $values as $v ){
$res += $this->insert_update($table, ... | php | public function insert_update($table, array $values = null): ?int {
// Twice the arguments
if ( \is_array($table) && isset($table['values']) ){
$values = $table['values'];
}
if ( !x::is_assoc($values) ){
$res = 0;
foreach ( $values as $v ){
$res += $this->insert_update($table, ... | [
"public",
"function",
"insert_update",
"(",
"$",
"table",
",",
"array",
"$",
"values",
"=",
"null",
")",
":",
"?",
"int",
"{",
"// Twice the arguments",
"if",
"(",
"\\",
"is_array",
"(",
"$",
"table",
")",
"&&",
"isset",
"(",
"$",
"table",
"[",
"'value... | If not exist inserts row(s) in a table, else update.
<code>
$this->db->insert_update(
"table_users",
[
'id' => '12',
'name' => 'Frank'
]
);
</code>
@param string|array $table The table name or the configuration array.
@param array $values The values to insert.
@return int The number of rows inserted or updated. | [
"If",
"not",
"exist",
"inserts",
"row",
"(",
"s",
")",
"in",
"a",
"table",
"else",
"update",
"."
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/db.php#L2928-L2965 |
nabab/bbn | src/bbn/db.php | db.update | public function update($table, array $values = null, array $where = null, bool $ignore = false): ?int
{
$cfg = \is_array($table) ? $table : [
'tables' => [$table],
'where' => $where,
'fields' => $values,
'ignore' => $ignore
];
$cfg['kind'] = 'UPDATE';
return $this->_exec($cfg);... | php | public function update($table, array $values = null, array $where = null, bool $ignore = false): ?int
{
$cfg = \is_array($table) ? $table : [
'tables' => [$table],
'where' => $where,
'fields' => $values,
'ignore' => $ignore
];
$cfg['kind'] = 'UPDATE';
return $this->_exec($cfg);... | [
"public",
"function",
"update",
"(",
"$",
"table",
",",
"array",
"$",
"values",
"=",
"null",
",",
"array",
"$",
"where",
"=",
"null",
",",
"bool",
"$",
"ignore",
"=",
"false",
")",
":",
"?",
"int",
"{",
"$",
"cfg",
"=",
"\\",
"is_array",
"(",
"$"... | Updates row(s) in a table.
<code>
$this->db->update(
"table_users",
[
['name' => 'Frank'],
['surname' => 'Red']
],
['id' => '127']
);
</code>
@param string|array $table The table name or the configuration array.
@param array $values The new value(s).
@param array $where The "where" condition.
@param boolean $ignore I... | [
"Updates",
"row",
"(",
"s",
")",
"in",
"a",
"table",
"."
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/db.php#L2988-L2998 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.