_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 83 13k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q26900 | BinaryNode.attachRight | train | public function attachRight(BinaryNode $node) : void
{
$node->setParent($this);
$this->right = $node;
} | php | {
"resource": ""
} |
q26901 | BinaryNode.detachLeft | train | public function detachLeft() : void
{
if ($this->left) {
$this->left->setParent(null);
$this->left = null;
}
} | php | {
"resource": ""
} |
q26902 | BinaryNode.detachRight | train | public function detachRight() : void
{
if ($this->right) {
$this->right->setParent(null);
$this->right = null;
}
} | php | {
"resource": ""
} |
q26903 | KMeans.predict | train | public function predict(Dataset $dataset) : array
{
if (!$this->centroids) {
throw new RuntimeException('Estimator has not been trained.');
}
DatasetIsCompatibleWithEstimator::check($dataset, $this);
return array_map([self::class, 'assign'], $dataset->samples());
} | php | {
"resource": ""
} |
q26904 | PersistentModel.load | train | public static function load(Persister $persister) : self
{
$learner = $persister->load();
if (!$learner instanceof Learner) {
throw new InvalidArgumentException('Peristable must be a'
. ' learner.');
}
return new self($learner, $persister);
} | php | {
"resource": ""
} |
q26905 | PersistentModel.save | train | public function save() : void
{
if ($this->base instanceof Persistable) {
$this->persister->save($this->base);
if ($this->logger) {
$this->logger->info('Model saved successully');
}
}
} | php | {
"resource": ""
} |
q26906 | RedisDB.save | train | public function save(Persistable $persistable) : void
{
$data = $this->serializer->serialize($persistable);
$success = $this->connector->set($this->key, $data);
if (!$success) {
throw new RuntimeException('Failed to save persistable'
. ' to the database.');
... | php | {
"resource": ""
} |
q26907 | WildGuess.guess | train | public function guess() : float
{
if ($this->min === null or $this->max === null) {
throw new RuntimeException('Strategy has not been fitted.');
}
$min = (int) round($this->min * $this->precision);
$max = (int) round($this->max * $this->precision);
return rand($... | php | {
"resource": ""
} |
q26908 | MCC.mcc | train | public static function mcc(int $tp, int $tn, int $fp, int $fn) : float
{
return ($tp * $tn - $fp * $fn)
/ (sqrt(($tp + $fp) * ($tp + $fn)
* ($tn + $fp) * ($tn + $fn)) ?: EPSILON);
} | php | {
"resource": ""
} |
q26909 | Ridge.predict | train | public function predict(Dataset $dataset) : array
{
if (!$this->weights or $this->bias === null) {
throw new RuntimeException('Estimator has not been trained.');
}
DatasetIsCompatibleWithEstimator::check($dataset, $this);
return Matrix::build($dataset->samples())
... | php | {
"resource": ""
} |
q26910 | MLPRegressor.predict | train | public function predict(Dataset $dataset) : array
{
if (!$this->network) {
throw new RuntimeException('The learner has not'
. ' been trained.');
}
DatasetIsCompatibleWithEstimator::check($dataset, $this);
$xT = Matrix::quick($dataset->samples())->transpo... | php | {
"resource": ""
} |
q26911 | Dropout.back | train | public function back(Deferred $prevGradient, Optimizer $optimizer) : Deferred
{
if (!$this->mask) {
throw new RuntimeException('Must perform forward pass before'
. ' backpropagating.');
}
$mask = $this->mask;
unset($this->mask);
return new Defer... | php | {
"resource": ""
} |
q26912 | Minkowski.compute | train | public function compute(array $a, array $b) : float
{
$distance = 0.;
foreach ($a as $i => $value) {
$distance += abs($value - $b[$i]) ** $this->lambda;
}
return $distance ** $this->inverse;
} | php | {
"resource": ""
} |
q26913 | Stats.mean | train | public static function mean(array $values, ?int $n = null) : float
{
$n = $n ?? count($values);
if ($n < 1) {
throw new InvalidArgumentException('Mean is undefined for empty'
. ' set.');
}
return array_sum($values) / $n;
} | php | {
"resource": ""
} |
q26914 | Stats.weightedMean | train | public static function weightedMean(array $values, array $weights, ?int $n = null) : float
{
$n = $n ?? count($values);
if ($n < 1) {
throw new InvalidArgumentException('Mean is undefined for empty'
. ' set.');
}
if (count($weights) !== $n) {
... | php | {
"resource": ""
} |
q26915 | Stats.mode | train | public static function mode(array $values) : float
{
if (empty($values)) {
throw new InvalidArgumentException('Mode is undefined for empty'
. ' set.');
}
$counts = array_count_values(array_map('strval', $values));
return (float) argmax($counts);
} | php | {
"resource": ""
} |
q26916 | Stats.variance | train | public static function variance(array $values, ?float $mean = null, ?int $n = null) : float
{
$n = $n ?? count($values);
if ($n < 1) {
throw new InvalidArgumentException('Variance is undefined for an'
. ' empty set.');
}
$mean = $mean ?? self::mean($valu... | php | {
"resource": ""
} |
q26917 | Stats.median | train | public static function median(array $values) : float
{
$n = count($values);
if ($n < 1) {
throw new InvalidArgumentException('Median is undefined for empty'
. ' set.');
}
$mid = intdiv($n, 2);
sort($values);
if ($n % 2 === 1) {
... | php | {
"resource": ""
} |
q26918 | Stats.percentile | train | public static function percentile(array $values, float $p) : float
{
if (empty($values)) {
throw new InvalidArgumentException('Percentile is not defined for'
. ' an empty set.');
}
if ($p < 0. or $p > 100.) {
throw new InvalidArgumentException('P must... | php | {
"resource": ""
} |
q26919 | Stats.iqr | train | public static function iqr(array $values) : float
{
$n = count($values);
if ($n < 1) {
throw new InvalidArgumentException('Interquartile range is not'
. ' defined for empty set.');
}
$mid = intdiv($n, 2);
sort($values);
if ($n % 2 === 0... | php | {
"resource": ""
} |
q26920 | Stats.mad | train | public static function mad(array $values, ?float $median = null) : float
{
$median = $median ?? self::median($values);
$deviations = [];
foreach ($values as $value) {
$deviations[] = abs($value - $median);
}
return self::median($deviations);
} | php | {
"resource": ""
} |
q26921 | Stats.centralMoment | train | public static function centralMoment(array $values, int $moment, ?float $mean = null, ?int $n = null) : float
{
$n = $n ?? count($values);
if ($n < 1) {
throw new InvalidArgumentException('Central moment is undefined for'
. ' empty set.');
}
$mean = $mea... | php | {
"resource": ""
} |
q26922 | Stats.skewness | train | public static function skewness(array $values, ?float $mean = null, ?int $n = null) : float
{
$n = $n ?? count($values);
if ($n === 0) {
throw new InvalidArgumentException('Skewness is undefined for'
. ' empty set.');
}
$mean = $mean ?? self::mean($value... | php | {
"resource": ""
} |
q26923 | Stats.range | train | public static function range(array $values) : float
{
if (empty($values)) {
throw new InvalidArgumentException('Range is undefined for empty'
. ' set.');
}
return (float) (max($values) - min($values));
} | php | {
"resource": ""
} |
q26924 | Stats.meanVar | train | public static function meanVar(array $values) : array
{
$mean = self::mean($values);
return [$mean, self::variance($values, $mean)];
} | php | {
"resource": ""
} |
q26925 | Stats.medMad | train | public static function medMad(array $values) : array
{
$median = self::median($values);
return [$median, self::mad($values, $median)];
} | php | {
"resource": ""
} |
q26926 | CrossEntropy.compute | train | public function compute(Tensor $expected, Tensor $output) : float
{
return $expected->negate()->multiply($output->log())->sum()->mean();
} | php | {
"resource": ""
} |
q26927 | CART.search | train | public function search(array $sample) : ?BinaryNode
{
$current = $this->root;
while ($current) {
if ($current instanceof Decision) {
$value = $current->value();
if (is_string($value)) {
if ($sample[$current->column()] === $value) {
... | php | {
"resource": ""
} |
q26928 | CART.featureImportances | train | public function featureImportances() : array
{
if (!$this->root) {
return [];
}
$importances = array_fill(0, $this->featureCount, 0.);
foreach ($this->dump() as $node) {
if ($node instanceof Decision) {
$index = $node->column();
... | php | {
"resource": ""
} |
q26929 | CART.dump | train | public function dump() : Generator
{
$nodes = [];
$stack = [$this->root];
while ($stack) {
$current = array_pop($stack);
if ($current instanceof BinaryNode) {
foreach ($current->children() as $child) {
$stack[] = $child;
... | php | {
"resource": ""
} |
q26930 | Cell.c | train | protected static function c(int $n) : float
{
if ($n <= 1) {
return 1.;
}
return 2. * (log($n - 1) + M_EULER) - 2. * ($n - 1) / $n;
} | php | {
"resource": ""
} |
q26931 | MatrixParam.update | train | public function update(Tensor $step) : void
{
$this->w = $this->w()->subtract($step);
} | php | {
"resource": ""
} |
q26932 | RegressionTree.train | train | public function train(Dataset $dataset) : void
{
if (!$dataset instanceof Labeled) {
throw new InvalidArgumentException('This estimator requires a'
. ' labeled training set.');
}
DatasetIsCompatibleWithEstimator::check($dataset, $this);
$k = $dataset->nu... | php | {
"resource": ""
} |
q26933 | RegressionTree.predict | train | public function predict(Dataset $dataset) : array
{
if ($this->bare()) {
throw new RuntimeException('Estimator has not been trained.');
}
DatasetIsCompatibleWithEstimator::check($dataset, $this);
$predictions = [];
foreach ($dataset as $sample) {
$n... | php | {
"resource": ""
} |
q26934 | RegressionTree.split | train | protected function split(Labeled $dataset) : Decision
{
$bestVariance = INF;
$bestColumn = $bestValue = null;
$bestGroups = [];
shuffle($this->columns);
foreach (array_slice($this->columns, 0, $this->maxFeatures) as $column) {
$values = array_unique($dataset->co... | php | {
"resource": ""
} |
q26935 | RegressionTree.terminate | train | protected function terminate(Labeled $dataset) : BinaryNode
{
[$mean, $variance] = Stats::meanVar($dataset->labels());
return new Average($mean, $variance, $dataset->numRows());
} | php | {
"resource": ""
} |
q26936 | RegressionTree.splitImpurity | train | protected function splitImpurity(array $groups) : float
{
$n = array_sum(array_map('count', $groups));
$impurity = 0.;
foreach ($groups as $dataset) {
$k = $dataset->numRows();
if ($k < 2) {
continue 1;
}
$variance = Stats::... | php | {
"resource": ""
} |
q26937 | RandomForest.featureImportances | train | public function featureImportances() : array
{
if (!$this->forest or !$this->featureCount) {
return [];
}
$importances = array_fill(0, $this->featureCount, 0.);
foreach ($this->forest as $tree) {
foreach ($tree->featureImportances() as $column => $value) {
... | php | {
"resource": ""
} |
q26938 | BlurryPercentile.gaussian | train | public static function gaussian() : float
{
$r1 = rand(0, PHP_INT_MAX) / PHP_INT_MAX;
$r2 = rand(0, PHP_INT_MAX) / PHP_INT_MAX;
return sqrt(-2. * log($r1)) * cos(TWO_PI * $r2);
} | php | {
"resource": ""
} |
q26939 | Adam.warm | train | public function warm(Parameter $param) : void
{
$velocity = get_class($param->w())::zeros(...$param->w()->shape());
$g2 = clone $velocity;
$this->cache[$param->id()] = [$velocity, $g2];
} | php | {
"resource": ""
} |
q26940 | Adam.step | train | public function step(Parameter $param, Tensor $gradient) : void
{
[$velocity, $g2] = $this->cache[$param->id()];
$velocity = $velocity->multiply($this->momentumDecay)
->add($gradient->multiply(1. - $this->momentumDecay));
$g2 = $g2->multiply($this->rmsDecay)
->add($... | php | {
"resource": ""
} |
q26941 | Softmax.compute | train | public function compute(Matrix $z) : Matrix
{
$zHat = $z->transpose()->exp();
$total = $zHat->sum();
return $zHat->divide($total)->transpose();
} | php | {
"resource": ""
} |
q26942 | FBeta.precision | train | public static function precision(int $tp, int $fp) : float
{
return $tp / (($tp + $fp) ?: EPSILON);
} | php | {
"resource": ""
} |
q26943 | FBeta.recall | train | public static function recall(int $tp, int $fn) : float
{
return $tp / (($tp + $fn) ?: EPSILON);
} | php | {
"resource": ""
} |
q26944 | Filesystem.save | train | public function save(Persistable $persistable) : void
{
if ($this->history and is_file($this->path)) {
$filename = $this->path . '.' . (string) time() . self::HISTORY_EXT;
if (!rename($this->path, $filename)) {
throw new RuntimeException('Failed to rename history,'
... | php | {
"resource": ""
} |
q26945 | ITree.search | train | public function search(array $sample) : ?Cell
{
$current = $this->root;
while ($current) {
if ($current instanceof Isolator) {
$value = $current->value();
if (is_string($value)) {
if ($sample[$current->column()] === $value) {
... | php | {
"resource": ""
} |
q26946 | Decision.purityIncrease | train | public function purityIncrease() : float
{
$impurity = $this->impurity;
if ($this->left instanceof Purity) {
$impurity -= $this->left->impurity()
* ($this->left->n() / $this->n);
}
if ($this->right instanceof Purity) {
$impurity -= $this->rig... | php | {
"resource": ""
} |
q26947 | NaiveBayes.priors | train | public function priors() : array
{
$priors = [];
if (is_array($this->priors)) {
$max = logsumexp($this->priors);
foreach ($this->priors as $class => $probability) {
$priors[$class] = exp($probability - $max);
}
}
return $priors;
... | php | {
"resource": ""
} |
q26948 | NaiveBayes.partial | train | public function partial(Dataset $dataset) : void
{
if (!$dataset instanceof Labeled) {
throw new InvalidArgumentException('This Estimator requires a'
. ' Labeled training set.');
}
if (!$dataset->homogeneous() or $dataset->columnType(0) !== DataType::CATEGORICAL)... | php | {
"resource": ""
} |
q26949 | AdaBoost.score | train | protected function score(Dataset $dataset) : array
{
$scores = array_fill(
0,
$dataset->numRows(),
array_fill_keys($this->classes, 0.)
);
foreach ($this->ensemble as $i => $estimator) {
$influence = $this->influences[$i];
foreach ... | php | {
"resource": ""
} |
q26950 | KNearestNeighbors.partial | train | public function partial(Dataset $dataset) : void
{
if (!$dataset instanceof Labeled) {
throw new InvalidArgumentException('This estimator requires a'
. ' labeled training set.');
}
DatasetIsCompatibleWithEstimator::check($dataset, $this);
$this->classes ... | php | {
"resource": ""
} |
q26951 | FeedForward.layers | train | public function layers() : Generator
{
yield $this->input;
foreach ($this->hidden as $hidden) {
yield $hidden;
}
yield $this->output;
} | php | {
"resource": ""
} |
q26952 | FeedForward.parametric | train | public function parametric() : Generator
{
foreach ($this->hidden as $layer) {
if ($layer instanceof Parametric) {
yield $layer;
}
}
if ($this->output instanceof Parametric) {
yield $this->output;
}
} | php | {
"resource": ""
} |
q26953 | FeedForward.roundtrip | train | public function roundtrip(Labeled $batch) : float
{
$input = Matrix::quick($batch->samples())->transpose();
$this->feed($input);
return $this->backpropagate($batch->labels());
} | php | {
"resource": ""
} |
q26954 | FeedForward.feed | train | public function feed(Matrix $input) : Matrix
{
$input = $this->input->forward($input);
foreach ($this->hidden as $hidden) {
$input = $hidden->forward($input);
}
return $this->output->forward($input);
} | php | {
"resource": ""
} |
q26955 | FeedForward.infer | train | public function infer(Matrix $input) : Tensor
{
$input = $this->input->infer($input);
foreach ($this->hidden as $hidden) {
$input = $hidden->infer($input);
}
return $this->output->infer($input);
} | php | {
"resource": ""
} |
q26956 | FeedForward.backpropagate | train | public function backpropagate(array $labels) : float
{
[$gradient, $loss] = $this->output->back($labels, $this->optimizer);
foreach ($this->backPass as $layer) {
$gradient = $layer->back($gradient, $this->optimizer);
}
return $loss;
} | php | {
"resource": ""
} |
q26957 | FeedForward.restore | train | public function restore(Snapshot $snapshot) : void
{
foreach ($snapshot as [$layer, $params]) {
if ($layer instanceof Parametric) {
$layer->restore($params);
}
}
} | php | {
"resource": ""
} |
q26958 | KDTree.search | train | public function search(array $sample) : ?Neighborhood
{
$current = $this->root;
while ($current) {
if ($current instanceof Coordinate) {
if ($sample[$current->column()] < $current->value()) {
$current = $current->left();
} else {
... | php | {
"resource": ""
} |
q26959 | KDTree.nearest | train | public function nearest(array $sample, int $k = 1) : array
{
if ($k < 1) {
throw new InvalidArgumentException('The number of nearest'
. " neighbors must be greater than 0, $k given.");
}
$neighborhood = $this->search($sample);
if (!$neighborhood) {
... | php | {
"resource": ""
} |
q26960 | BallTree.range | train | public function range(array $sample, float $radius) : array
{
if ($radius <= 0.) {
throw new InvalidArgumentException('Radius must be'
. " greater than 0, $radius given.");
}
$samples = $labels = $distances = [];
$stack = [$this->root];
while ($... | php | {
"resource": ""
} |
q26961 | DataType.determine | train | public static function determine($data) : int
{
switch (gettype($data)) {
case 'string':
return self::CATEGORICAL;
case 'double':
return self::CONTINUOUS;
case 'integer':
return self::CONTINUOUS;
case 'resourc... | php | {
"resource": ""
} |
q26962 | Coordinate.split | train | public static function split(Labeled $dataset) : self
{
$columns = $dataset->columns();
$variances = array_map([Stats::class, 'variance'], $columns);
$column = argmax($variances);
$value = Stats::median($columns[$column]);
$groups = $dataset->partition($column, $value);
... | php | {
"resource": ""
} |
q26963 | Mysqldump.array_replace_recursive | train | public static function array_replace_recursive($array1, $array2)
{
if (function_exists('array_replace_recursive')) {
return array_replace_recursive($array1, $array2);
}
foreach ($array2 as $key => $value) {
if (is_array($value)) {
$array1[$key] = self... | php | {
"resource": ""
} |
q26964 | Mysqldump.getTableLimit | train | public function getTableLimit($tableName)
{
if (empty($this->tableLimits[$tableName])) {
return false;
}
$limit = $this->tableLimits[$tableName];
if (!is_numeric($limit)) {
return false;
}
return $limit;
} | php | {
"resource": ""
} |
q26965 | Mysqldump.connect | train | private function connect()
{
// Connecting with PDO.
try {
switch ($this->dbType) {
case 'sqlite':
$this->dbHandler = @new PDO("sqlite:".$this->dbName, null, null, $this->pdoSettings);
break;
case 'mysql':
... | php | {
"resource": ""
} |
q26966 | Mysqldump.start | train | public function start($filename = '')
{
// Output file can be redefined here
if (!empty($filename)) {
$this->fileName = $filename;
}
// Connect to database
$this->connect();
// Create output file
$this->compressManager->open($this->fileName);
... | php | {
"resource": ""
} |
q26967 | Mysqldump.getDumpFileHeader | train | private function getDumpFileHeader()
{
$header = '';
if (!$this->dumpSettings['skip-comments']) {
// Some info about software, source and time
$header = "-- mysqldump-php https://github.com/ifsnop/mysqldump-php".PHP_EOL.
"--".PHP_EOL.
"... | php | {
"resource": ""
} |
q26968 | Mysqldump.getDumpFileFooter | train | private function getDumpFileFooter()
{
$footer = '';
if (!$this->dumpSettings['skip-comments']) {
$footer .= '-- Dump completed';
if (!$this->dumpSettings['skip-dump-date']) {
$footer .= ' on: '.date('r');
}
$footer .= PHP_EOL;
... | php | {
"resource": ""
} |
q26969 | Mysqldump.exportTables | train | private function exportTables()
{
// Exporting tables one by one
foreach ($this->tables as $table) {
if ($this->matches($table, $this->dumpSettings['exclude-tables'])) {
continue;
}
$this->getTableStructure($table);
if (false === $this-... | php | {
"resource": ""
} |
q26970 | Mysqldump.exportViews | train | private function exportViews()
{
if (false === $this->dumpSettings['no-create-info']) {
// Exporting views one by one
foreach ($this->views as $view) {
if ($this->matches($view, $this->dumpSettings['exclude-tables'])) {
continue;
}
... | php | {
"resource": ""
} |
q26971 | Mysqldump.getTableStructure | train | private function getTableStructure($tableName)
{
if (!$this->dumpSettings['no-create-info']) {
$ret = '';
if (!$this->dumpSettings['skip-comments']) {
$ret = "--".PHP_EOL.
"-- Table structure for table `$tableName`".PHP_EOL.
"--... | php | {
"resource": ""
} |
q26972 | Mysqldump.getTableColumnTypes | train | private function getTableColumnTypes($tableName)
{
$columnTypes = array();
$columns = $this->dbHandler->query(
$this->typeAdapter->show_columns($tableName)
);
$columns->setFetchMode(PDO::FETCH_ASSOC);
foreach ($columns as $key => $col) {
$types = $thi... | php | {
"resource": ""
} |
q26973 | Mysqldump.createStandInTable | train | public function createStandInTable($viewName)
{
$ret = array();
foreach ($this->tableColumnTypes[$viewName] as $k => $v) {
$ret[] = "`${k}` ${v['type_sql']}";
}
$ret = implode(PHP_EOL.",", $ret);
$ret = "CREATE TABLE IF NOT EXISTS `$viewName` (".
PHP_... | php | {
"resource": ""
} |
q26974 | Mysqldump.getViewStructureView | train | private function getViewStructureView($viewName)
{
if (!$this->dumpSettings['skip-comments']) {
$ret = "--".PHP_EOL.
"-- View structure for view `${viewName}`".PHP_EOL.
"--".PHP_EOL.PHP_EOL;
$this->compressManager->write($ret);
}
$stmt ... | php | {
"resource": ""
} |
q26975 | Mysqldump.getTriggerStructure | train | private function getTriggerStructure($triggerName)
{
$stmt = $this->typeAdapter->show_create_trigger($triggerName);
foreach ($this->dbHandler->query($stmt) as $r) {
if ($this->dumpSettings['add-drop-trigger']) {
$this->compressManager->write(
$this->ty... | php | {
"resource": ""
} |
q26976 | Mysqldump.getProcedureStructure | train | private function getProcedureStructure($procedureName)
{
if (!$this->dumpSettings['skip-comments']) {
$ret = "--".PHP_EOL.
"-- Dumping routines for database '".$this->dbName."'".PHP_EOL.
"--".PHP_EOL.PHP_EOL;
$this->compressManager->write($ret);
... | php | {
"resource": ""
} |
q26977 | Mysqldump.getEventStructure | train | private function getEventStructure($eventName)
{
if (!$this->dumpSettings['skip-comments']) {
$ret = "--".PHP_EOL.
"-- Dumping events for database '".$this->dbName."'".PHP_EOL.
"--".PHP_EOL.PHP_EOL;
$this->compressManager->write($ret);
}
... | php | {
"resource": ""
} |
q26978 | Mysqldump.prepareColumnValues | train | private function prepareColumnValues($tableName, $row)
{
$ret = array();
$columnTypes = $this->tableColumnTypes[$tableName];
foreach ($row as $colName => $colValue) {
$colValue = $this->hookTransformColumnValue($tableName, $colName, $colValue, $row);
$ret[] = $this->e... | php | {
"resource": ""
} |
q26979 | Mysqldump.escape | train | private function escape($colValue, $colType)
{
if (is_null($colValue)) {
return "NULL";
} elseif ($this->dumpSettings['hex-blob'] && $colType['is_blob']) {
if ($colType['type'] == 'bit' || !empty($colValue)) {
return "0x${colValue}";
} else {
... | php | {
"resource": ""
} |
q26980 | Mysqldump.hookTransformColumnValue | train | protected function hookTransformColumnValue($tableName, $colName, $colValue, $row)
{
if (!$this->transformColumnValueCallable) {
return $colValue;
}
return call_user_func_array($this->transformColumnValueCallable, array(
$tableName,
$colName,
... | php | {
"resource": ""
} |
q26981 | Mysqldump.listValues | train | private function listValues($tableName)
{
$this->prepareListValues($tableName);
$onlyOnce = true;
$lineSize = 0;
// colStmt is used to form a query to obtain row values
$colStmt = $this->getColumnStmt($tableName);
// colNames is used to get the name of the columns w... | php | {
"resource": ""
} |
q26982 | Mysqldump.prepareListValues | train | public function prepareListValues($tableName)
{
if (!$this->dumpSettings['skip-comments']) {
$this->compressManager->write(
"--".PHP_EOL.
"-- Dumping data for table `$tableName`".PHP_EOL.
"--".PHP_EOL.PHP_EOL
);
}
if ($... | php | {
"resource": ""
} |
q26983 | Mysqldump.endListValues | train | public function endListValues($tableName, $count = 0)
{
if ($this->dumpSettings['disable-keys']) {
$this->compressManager->write(
$this->typeAdapter->end_add_disable_keys($tableName)
);
}
if ($this->dumpSettings['add-locks']) {
$this->comp... | php | {
"resource": ""
} |
q26984 | Mysqldump.getColumnStmt | train | public function getColumnStmt($tableName)
{
$colStmt = array();
foreach ($this->tableColumnTypes[$tableName] as $colName => $colType) {
if ($colType['type'] == 'bit' && $this->dumpSettings['hex-blob']) {
$colStmt[] = "LPAD(HEX(`${colName}`),2,'0') AS `${colName}`";
... | php | {
"resource": ""
} |
q26985 | Mysqldump.getColumnNames | train | public function getColumnNames($tableName)
{
$colNames = array();
foreach ($this->tableColumnTypes[$tableName] as $colName => $colType) {
if ($colType['is_virtual']) {
$this->dumpSettings['complete-insert'] = true;
continue;
} else {
... | php | {
"resource": ""
} |
q26986 | TypeAdapterMysql.parseColumnType | train | public function parseColumnType($colType)
{
$colInfo = array();
$colParts = explode(" ", $colType['Type']);
if ($fparen = strpos($colParts[0], "(")) {
$colInfo['type'] = substr($colParts[0], 0, $fparen);
$colInfo['length'] = str_replace(")", "", substr($colParts[0], ... | php | {
"resource": ""
} |
q26987 | TrustProxies.setTrustedProxyIpAddresses | train | protected function setTrustedProxyIpAddresses(Request $request)
{
$trustedIps = $this->proxies ?: $this->config->get('trustedproxy.proxies');
// Trust any IP address that calls us
// `**` for backwards compatibility, but is deprecated
if ($trustedIps === '*' || $trustedIps === '**')... | php | {
"resource": ""
} |
q26988 | TrustProxies.setTrustedProxyIpAddressesToTheCallingIp | train | private function setTrustedProxyIpAddressesToTheCallingIp(Request $request)
{
$request->setTrustedProxies([$request->server->get('REMOTE_ADDR')], $this->getTrustedHeaderNames());
} | php | {
"resource": ""
} |
q26989 | Oci8Connection.setSchema | train | public function setSchema($schema)
{
$this->schema = $schema;
$sessionVars = [
'CURRENT_SCHEMA' => $schema,
];
return $this->setSessionVars($sessionVars);
} | php | {
"resource": ""
} |
q26990 | Oci8Connection.setSessionVars | train | public function setSessionVars(array $sessionVars)
{
$vars = [];
foreach ($sessionVars as $option => $value) {
if (strtoupper($option) == 'CURRENT_SCHEMA' || strtoupper($option) == 'EDITION') {
$vars[] = "$option = $value";
} else {
$vars[] = ... | php | {
"resource": ""
} |
q26991 | Oci8Connection.getDoctrineConnection | train | public function getDoctrineConnection()
{
if (is_null($this->doctrineConnection)) {
$data = ['pdo' => $this->getPdo(), 'user' => $this->getConfig('username')];
$this->doctrineConnection = new DoctrineConnection(
$data,
$this->getDoc... | php | {
"resource": ""
} |
q26992 | Oci8Connection.createSqlFromProcedure | train | public function createSqlFromProcedure($procedureName, array $bindings, $cursor = false)
{
$paramsString = implode(',', array_map(function ($param) {
return ':' . $param;
}, array_keys($bindings)));
$prefix = count($bindings) ? ',' : '';
$cursor = $cursor ? $prefix . $cu... | php | {
"resource": ""
} |
q26993 | Oci8Connection.createStatementFromProcedure | train | public function createStatementFromProcedure($procedureName, array $bindings, $cursorName = false)
{
$sql = $this->createSqlFromProcedure($procedureName, $bindings, $cursorName);
return $this->getPdo()->prepare($sql);
} | php | {
"resource": ""
} |
q26994 | Oci8Connection.createStatementFromFunction | train | public function createStatementFromFunction($functionName, array $bindings)
{
$bindings = $bindings ? ':' . implode(', :', array_keys($bindings)) : '';
$sql = sprintf('begin :result := %s(%s); end;', $functionName, $bindings);
return $this->getPdo()->prepare($sql);
} | php | {
"resource": ""
} |
q26995 | Oci8Connection.addBindingsToStatement | train | public function addBindingsToStatement(PDOStatement $stmt, array $bindings)
{
foreach ($bindings as $key => &$binding) {
$value = &$binding;
$type = PDO::PARAM_STR;
$length = -1;
if (is_array($binding)) {
$value = &$binding['value'];
... | php | {
"resource": ""
} |
q26996 | Oci8Connection.causedByLostConnection | train | protected function causedByLostConnection(Throwable $e)
{
if (parent::causedByLostConnection($e)) {
return true;
}
$lostConnectionErrors = [
'ORA-03113', //End-of-file on communication channel
'ORA-03114', //Not Connected to Oracle
'ORA-... | php | {
"resource": ""
} |
q26997 | OracleEloquent.extractBinaries | train | protected function extractBinaries(&$attributes)
{
// If attributes contains binary field
// extract binary fields to new array
$binaries = [];
if ($this->checkBinary($attributes) && $this->getConnection() instanceof Oci8Connection) {
foreach ($attributes as $key => $valu... | php | {
"resource": ""
} |
q26998 | OracleEloquent.checkBinary | train | protected function checkBinary(array $attributes)
{
foreach ($attributes as $key => $value) {
// if attribute is in binary field list
if (in_array($key, $this->binaries)) {
return true;
}
}
return false;
} | php | {
"resource": ""
} |
q26999 | Sequence.create | train | public function create($name, $start = 1, $nocache = false, $min = 1, $max = false, $increment = 1)
{
if (! $name) {
return false;
}
if ($this->connection->getConfig('prefix_schema')) {
$name = $this->connection->getConfig('prefix_schema') . '.' . $name;
}
... | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.