_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q241800
ActiveDataFilter.buildAttributeCondition
validation
protected function buildAttributeCondition($attribute, $condition) { if (is_array($condition)) { $parts = []; foreach ($condition as $operator => $value) { if (isset($this->operatorTypes[$operator])) { if (isset($this->conditionBuilders[$operator])) { $method = $this->conditionBuilders[$operator]; if (is_string($method)) { $callback = [$this, $method]; } else { $callback = $method; } $parts[] = $callback($operator, $value, $attribute); } else { $parts[] = $this->buildOperatorCondition($operator, $value, $attribute); } } } if (!empty($parts)) { if (count($parts) > 1) { return array_merge(['AND'], $parts); } return array_shift($parts); } } return [$attribute => $this->filterAttributeValue($attribute, $condition)]; }
php
{ "resource": "" }
q241801
ActiveDataFilter.buildOperatorCondition
validation
protected function buildOperatorCondition($operator, $condition, $attribute) { if (isset($this->queryOperatorMap[$operator])) { $operator = $this->queryOperatorMap[$operator]; } return [$operator, $attribute, $this->filterAttributeValue($attribute, $condition)]; }
php
{ "resource": "" }
q241802
BaseYii.autoload
validation
public static function autoload($className) { if (isset(static::$classMap[$className])) { $classFile = static::$classMap[$className]; if ($classFile[0] === '@') { $classFile = static::getAlias($classFile); } } elseif (strpos($className, '\\') !== false) { $classFile = static::getAlias('@' . str_replace('\\', '/', $className) . '.php', false); if ($classFile === false || !is_file($classFile)) { return; } } else { return; } include $classFile; if (YII_DEBUG && !class_exists($className, false) && !interface_exists($className, false) && !trait_exists($className, false)) { throw new UnknownClassException("Unable to find '$className' in file: $classFile. Namespace missing?"); } }
php
{ "resource": "" }
q241803
BaseYii.debug
validation
public static function debug($message, $category = 'application') { if (YII_DEBUG) { static::getLogger()->log($message, Logger::LEVEL_TRACE, $category); } }
php
{ "resource": "" }
q241804
BaseListView.renderSummary
validation
public function renderSummary() { $count = $this->dataProvider->getCount(); if ($count <= 0) { return ''; } $summaryOptions = $this->summaryOptions; $tag = ArrayHelper::remove($summaryOptions, 'tag', 'div'); if (($pagination = $this->dataProvider->getPagination()) !== false) { $totalCount = $this->dataProvider->getTotalCount(); $begin = $pagination->getPage() * $pagination->pageSize + 1; $end = $begin + $count - 1; if ($begin > $end) { $begin = $end; } $page = $pagination->getPage() + 1; $pageCount = $pagination->pageCount; if (($summaryContent = $this->summary) === null) { return Html::tag($tag, Yii::t('yii', 'Showing <b>{begin, number}-{end, number}</b> of <b>{totalCount, number}</b> {totalCount, plural, one{item} other{items}}.', [ 'begin' => $begin, 'end' => $end, 'count' => $count, 'totalCount' => $totalCount, 'page' => $page, 'pageCount' => $pageCount, ]), $summaryOptions); } } else { $begin = $page = $pageCount = 1; $end = $totalCount = $count; if (($summaryContent = $this->summary) === null) { return Html::tag($tag, Yii::t('yii', 'Total <b>{count, number}</b> {count, plural, one{item} other{items}}.', [ 'begin' => $begin, 'end' => $end, 'count' => $count, 'totalCount' => $totalCount, 'page' => $page, 'pageCount' => $pageCount, ]), $summaryOptions); } } return Yii::$app->getI18n()->format($summaryContent, [ 'begin' => $begin, 'end' => $end, 'count' => $count, 'totalCount' => $totalCount, 'page' => $page, 'pageCount' => $pageCount, ], Yii::$app->language); }
php
{ "resource": "" }
q241805
BaseListView.renderSorter
validation
public function renderSorter() { $sort = $this->dataProvider->getSort(); if ($sort === false || empty($sort->attributes) || $this->dataProvider->getCount() <= 0) { return ''; } /* @var $class LinkSorter */ $sorter = $this->sorter; $class = ArrayHelper::remove($sorter, 'class', LinkSorter::className()); $sorter['sort'] = $sort; $sorter['view'] = $this->getView(); return $class::widget($sorter); }
php
{ "resource": "" }
q241806
Request.getScriptFile
validation
public function getScriptFile() { if ($this->_scriptFile === null) { if (isset($_SERVER['SCRIPT_FILENAME'])) { $this->setScriptFile($_SERVER['SCRIPT_FILENAME']); } else { throw new InvalidConfigException('Unable to determine the entry script file path.'); } } return $this->_scriptFile; }
php
{ "resource": "" }
q241807
Request.setScriptFile
validation
public function setScriptFile($value) { $scriptFile = realpath(Yii::getAlias($value)); if ($scriptFile !== false && is_file($scriptFile)) { $this->_scriptFile = $scriptFile; } else { throw new InvalidConfigException('Unable to determine the entry script file path.'); } }
php
{ "resource": "" }
q241808
DateValidator.parseDateValueFormat
validation
private function parseDateValueFormat($value, $format) { if (is_array($value)) { return false; } if (strncmp($format, 'php:', 4) === 0) { $format = substr($format, 4); } else { if (extension_loaded('intl')) { return $this->parseDateValueIntl($value, $format); } // fallback to PHP if intl is not installed $format = FormatConverter::convertDateIcuToPhp($format, 'date'); } return $this->parseDateValuePHP($value, $format); }
php
{ "resource": "" }
q241809
DateValidator.formatTimestamp
validation
private function formatTimestamp($timestamp, $format) { if (strncmp($format, 'php:', 4) === 0) { $format = substr($format, 4); } else { $format = FormatConverter::convertDateIcuToPhp($format, 'date'); } $date = new DateTime(); $date->setTimestamp($timestamp); $date->setTimezone(new \DateTimeZone($this->timestampAttributeTimeZone)); return $date->format($format); }
php
{ "resource": "" }
q241810
Security.encrypt
validation
protected function encrypt($data, $passwordBased, $secret, $info) { if (!extension_loaded('openssl')) { throw new InvalidConfigException('Encryption requires the OpenSSL PHP extension'); } if (!isset($this->allowedCiphers[$this->cipher][0], $this->allowedCiphers[$this->cipher][1])) { throw new InvalidConfigException($this->cipher . ' is not an allowed cipher'); } list($blockSize, $keySize) = $this->allowedCiphers[$this->cipher]; $keySalt = $this->generateRandomKey($keySize); if ($passwordBased) { $key = $this->pbkdf2($this->kdfHash, $secret, $keySalt, $this->derivationIterations, $keySize); } else { $key = $this->hkdf($this->kdfHash, $secret, $keySalt, $info, $keySize); } $iv = $this->generateRandomKey($blockSize); $encrypted = openssl_encrypt($data, $this->cipher, $key, OPENSSL_RAW_DATA, $iv); if ($encrypted === false) { throw new \yii\base\Exception('OpenSSL failure on encryption: ' . openssl_error_string()); } $authKey = $this->hkdf($this->kdfHash, $key, null, $this->authKeyInfo, $keySize); $hashed = $this->hashData($iv . $encrypted, $authKey); /* * Output: [keySalt][MAC][IV][ciphertext] * - keySalt is KEY_SIZE bytes long * - MAC: message authentication code, length same as the output of MAC_HASH * - IV: initialization vector, length $blockSize */ return $keySalt . $hashed; }
php
{ "resource": "" }
q241811
Security.validateData
validation
public function validateData($data, $key, $rawHash = false) { $test = @hash_hmac($this->macHash, '', '', $rawHash); if (!$test) { throw new InvalidConfigException('Failed to generate HMAC with hash algorithm: ' . $this->macHash); } $hashLength = StringHelper::byteLength($test); if (StringHelper::byteLength($data) >= $hashLength) { $hash = StringHelper::byteSubstr($data, 0, $hashLength); $pureData = StringHelper::byteSubstr($data, $hashLength, null); $calculatedHash = hash_hmac($this->macHash, $pureData, $key, $rawHash); if ($this->compareString($hash, $calculatedHash)) { return $pureData; } } return false; }
php
{ "resource": "" }
q241812
Security.generatePasswordHash
validation
public function generatePasswordHash($password, $cost = null) { if ($cost === null) { $cost = $this->passwordHashCost; } if (function_exists('password_hash')) { /* @noinspection PhpUndefinedConstantInspection */ return password_hash($password, PASSWORD_DEFAULT, ['cost' => $cost]); } $salt = $this->generateSalt($cost); $hash = crypt($password, $salt); // strlen() is safe since crypt() returns only ascii if (!is_string($hash) || strlen($hash) !== 60) { throw new Exception('Unknown error occurred while generating hash.'); } return $hash; }
php
{ "resource": "" }
q241813
Security.validatePassword
validation
public function validatePassword($password, $hash) { if (!is_string($password) || $password === '') { throw new InvalidArgumentException('Password must be a string and cannot be empty.'); } if (!preg_match('/^\$2[axy]\$(\d\d)\$[\.\/0-9A-Za-z]{22}/', $hash, $matches) || $matches[1] < 4 || $matches[1] > 30 ) { throw new InvalidArgumentException('Hash is invalid.'); } if (function_exists('password_verify')) { return password_verify($password, $hash); } $test = crypt($password, $hash); $n = strlen($test); if ($n !== 60) { return false; } return $this->compareString($test, $hash); }
php
{ "resource": "" }
q241814
Security.compareString
validation
public function compareString($expected, $actual) { if (!is_string($expected)) { throw new InvalidArgumentException('Expected expected value to be a string, ' . gettype($expected) . ' given.'); } if (!is_string($actual)) { throw new InvalidArgumentException('Expected actual value to be a string, ' . gettype($actual) . ' given.'); } if (function_exists('hash_equals')) { return hash_equals($expected, $actual); } $expected .= "\0"; $actual .= "\0"; $expectedLength = StringHelper::byteLength($expected); $actualLength = StringHelper::byteLength($actual); $diff = $expectedLength - $actualLength; for ($i = 0; $i < $actualLength; $i++) { $diff |= (ord($actual[$i]) ^ ord($expected[$i % $expectedLength])); } return $diff === 0; }
php
{ "resource": "" }
q241815
Security.unmaskToken
validation
public function unmaskToken($maskedToken) { $decoded = StringHelper::base64UrlDecode($maskedToken); $length = StringHelper::byteLength($decoded) / 2; // Check if the masked token has an even length. if (!is_int($length)) { return ''; } return StringHelper::byteSubstr($decoded, $length, $length) ^ StringHelper::byteSubstr($decoded, 0, $length); }
php
{ "resource": "" }
q241816
BlameableBehavior.getDefaultValue
validation
protected function getDefaultValue($event) { if ($this->defaultValue instanceof \Closure || (is_array($this->defaultValue) && is_callable($this->defaultValue))) { return call_user_func($this->defaultValue, $event); } return $this->defaultValue; }
php
{ "resource": "" }
q241817
OptionsAction.run
validation
public function run($id = null) { if (Yii::$app->getRequest()->getMethod() !== 'OPTIONS') { Yii::$app->getResponse()->setStatusCode(405); } $options = $id === null ? $this->collectionOptions : $this->resourceOptions; $headers = Yii::$app->getResponse()->getHeaders(); $headers->set('Allow', implode(', ', $options)); $headers->set('Access-Control-Allow-Methods', implode(', ', $options)); }
php
{ "resource": "" }
q241818
BaseUrl.normalizeRoute
validation
protected static function normalizeRoute($route) { $route = Yii::getAlias((string) $route); if (strncmp($route, '/', 1) === 0) { // absolute route return ltrim($route, '/'); } // relative route if (Yii::$app->controller === null) { throw new InvalidArgumentException("Unable to resolve the relative route: $route. No active controller is available."); } if (strpos($route, '/') === false) { // empty or an action ID return $route === '' ? Yii::$app->controller->getRoute() : Yii::$app->controller->getUniqueId() . '/' . $route; } // relative to module return ltrim(Yii::$app->controller->module->getUniqueId() . '/' . $route, '/'); }
php
{ "resource": "" }
q241819
BaseUrl.to
validation
public static function to($url = '', $scheme = false) { if (is_array($url)) { return static::toRoute($url, $scheme); } $url = Yii::getAlias($url); if ($url === '') { $url = Yii::$app->getRequest()->getUrl(); } if ($scheme === false) { return $url; } if (static::isRelative($url)) { // turn relative URL into absolute $url = static::getUrlManager()->getHostInfo() . '/' . ltrim($url, '/'); } return static::ensureScheme($url, $scheme); }
php
{ "resource": "" }
q241820
BaseUrl.ensureScheme
validation
public static function ensureScheme($url, $scheme) { if (static::isRelative($url) || !is_string($scheme)) { return $url; } if (substr($url, 0, 2) === '//') { // e.g. //example.com/path/to/resource return $scheme === '' ? $url : "$scheme:$url"; } if (($pos = strpos($url, '://')) !== false) { if ($scheme === '') { $url = substr($url, $pos + 1); } else { $url = $scheme . substr($url, $pos); } } return $url; }
php
{ "resource": "" }
q241821
BaseUrl.current
validation
public static function current(array $params = [], $scheme = false) { $currentParams = Yii::$app->getRequest()->getQueryParams(); $currentParams[0] = '/' . Yii::$app->controller->getRoute(); $route = array_replace_recursive($currentParams, $params); return static::toRoute($route, $scheme); }
php
{ "resource": "" }
q241822
AssetController.getAssetManager
validation
public function getAssetManager() { if (!is_object($this->_assetManager)) { $options = $this->_assetManager; if (!isset($options['class'])) { $options['class'] = 'yii\\web\\AssetManager'; } if (!isset($options['basePath'])) { throw new Exception("Please specify 'basePath' for the 'assetManager' option."); } if (!isset($options['baseUrl'])) { throw new Exception("Please specify 'baseUrl' for the 'assetManager' option."); } if (!isset($options['forceCopy'])) { $options['forceCopy'] = true; } $this->_assetManager = Yii::createObject($options); } return $this->_assetManager; }
php
{ "resource": "" }
q241823
AssetController.setAssetManager
validation
public function setAssetManager($assetManager) { if (is_scalar($assetManager)) { throw new Exception('"' . get_class($this) . '::assetManager" should be either object or array - "' . gettype($assetManager) . '" given.'); } $this->_assetManager = $assetManager; }
php
{ "resource": "" }
q241824
AssetController.actionCompress
validation
public function actionCompress($configFile, $bundleFile) { $this->loadConfiguration($configFile); $bundles = $this->loadBundles($this->bundles); $targets = $this->loadTargets($this->targets, $bundles); foreach ($targets as $name => $target) { $this->stdout("Creating output bundle '{$name}':\n"); if (!empty($target->js)) { $this->buildTarget($target, 'js', $bundles); } if (!empty($target->css)) { $this->buildTarget($target, 'css', $bundles); } $this->stdout("\n"); } $targets = $this->adjustDependency($targets, $bundles); $this->saveTargets($targets, $bundleFile); if ($this->deleteSource) { $this->deletePublishedAssets($bundles); } }
php
{ "resource": "" }
q241825
AssetController.loadConfiguration
validation
protected function loadConfiguration($configFile) { $this->stdout("Loading configuration from '{$configFile}'...\n"); $config = require $configFile; foreach ($config as $name => $value) { if (property_exists($this, $name) || $this->canSetProperty($name)) { $this->$name = $value; } else { throw new Exception("Unknown configuration option: $name"); } } $this->getAssetManager(); // check if asset manager configuration is correct }
php
{ "resource": "" }
q241826
AssetController.loadBundles
validation
protected function loadBundles($bundles) { $this->stdout("Collecting source bundles information...\n"); $am = $this->getAssetManager(); $result = []; foreach ($bundles as $name) { $result[$name] = $am->getBundle($name); } foreach ($result as $bundle) { $this->loadDependency($bundle, $result); } return $result; }
php
{ "resource": "" }
q241827
AssetController.loadDependency
validation
protected function loadDependency($bundle, &$result) { $am = $this->getAssetManager(); foreach ($bundle->depends as $name) { if (!isset($result[$name])) { $dependencyBundle = $am->getBundle($name); $result[$name] = false; $this->loadDependency($dependencyBundle, $result); $result[$name] = $dependencyBundle; } elseif ($result[$name] === false) { throw new Exception("A circular dependency is detected for bundle '{$name}': " . $this->composeCircularDependencyTrace($name, $result) . '.'); } } }
php
{ "resource": "" }
q241828
AssetController.buildTarget
validation
protected function buildTarget($target, $type, $bundles) { $inputFiles = []; foreach ($target->depends as $name) { if (isset($bundles[$name])) { if (!$this->isBundleExternal($bundles[$name])) { foreach ($bundles[$name]->$type as $file) { if (is_array($file)) { $inputFiles[] = $bundles[$name]->basePath . '/' . $file[0]; } else { $inputFiles[] = $bundles[$name]->basePath . '/' . $file; } } } } else { throw new Exception("Unknown bundle: '{$name}'"); } } if (empty($inputFiles)) { $target->$type = []; } else { FileHelper::createDirectory($target->basePath, $this->getAssetManager()->dirMode); $tempFile = $target->basePath . '/' . strtr($target->$type, ['{hash}' => 'temp']); if ($type === 'js') { $this->compressJsFiles($inputFiles, $tempFile); } else { $this->compressCssFiles($inputFiles, $tempFile); } $targetFile = strtr($target->$type, ['{hash}' => md5_file($tempFile)]); $outputFile = $target->basePath . '/' . $targetFile; rename($tempFile, $outputFile); $target->$type = [$targetFile]; } }
php
{ "resource": "" }
q241829
AssetController.adjustDependency
validation
protected function adjustDependency($targets, $bundles) { $this->stdout("Creating new bundle configuration...\n"); $map = []; foreach ($targets as $name => $target) { foreach ($target->depends as $bundle) { $map[$bundle] = $name; } } foreach ($targets as $name => $target) { $depends = []; foreach ($target->depends as $bn) { foreach ($bundles[$bn]->depends as $bundle) { $depends[$map[$bundle]] = true; } } unset($depends[$name]); $target->depends = array_keys($depends); } // detect possible circular dependencies foreach ($targets as $name => $target) { $registered = []; $this->registerBundle($targets, $name, $registered); } foreach ($map as $bundle => $target) { $sourceBundle = $bundles[$bundle]; $depends = $sourceBundle->depends; if (!$this->isBundleExternal($sourceBundle)) { $depends[] = $target; } $targetBundle = clone $sourceBundle; $targetBundle->depends = $depends; $targets[$bundle] = $targetBundle; } return $targets; }
php
{ "resource": "" }
q241830
AssetController.registerBundle
validation
protected function registerBundle($bundles, $name, &$registered) { if (!isset($registered[$name])) { $registered[$name] = false; $bundle = $bundles[$name]; foreach ($bundle->depends as $depend) { $this->registerBundle($bundles, $depend, $registered); } unset($registered[$name]); $registered[$name] = $bundle; } elseif ($registered[$name] === false) { throw new Exception("A circular dependency is detected for target '{$name}': " . $this->composeCircularDependencyTrace($name, $registered) . '.'); } }
php
{ "resource": "" }
q241831
AssetController.compressJsFiles
validation
protected function compressJsFiles($inputFiles, $outputFile) { if (empty($inputFiles)) { return; } $this->stdout(" Compressing JavaScript files...\n"); if (is_string($this->jsCompressor)) { $tmpFile = $outputFile . '.tmp'; $this->combineJsFiles($inputFiles, $tmpFile); $this->stdout(shell_exec(strtr($this->jsCompressor, [ '{from}' => escapeshellarg($tmpFile), '{to}' => escapeshellarg($outputFile), ]))); @unlink($tmpFile); } else { call_user_func($this->jsCompressor, $this, $inputFiles, $outputFile); } if (!file_exists($outputFile)) { throw new Exception("Unable to compress JavaScript files into '{$outputFile}'."); } $this->stdout(" JavaScript files compressed into '{$outputFile}'.\n"); }
php
{ "resource": "" }
q241832
AssetController.compressCssFiles
validation
protected function compressCssFiles($inputFiles, $outputFile) { if (empty($inputFiles)) { return; } $this->stdout(" Compressing CSS files...\n"); if (is_string($this->cssCompressor)) { $tmpFile = $outputFile . '.tmp'; $this->combineCssFiles($inputFiles, $tmpFile); $this->stdout(shell_exec(strtr($this->cssCompressor, [ '{from}' => escapeshellarg($tmpFile), '{to}' => escapeshellarg($outputFile), ]))); @unlink($tmpFile); } else { call_user_func($this->cssCompressor, $this, $inputFiles, $outputFile); } if (!file_exists($outputFile)) { throw new Exception("Unable to compress CSS files into '{$outputFile}'."); } $this->stdout(" CSS files compressed into '{$outputFile}'.\n"); }
php
{ "resource": "" }
q241833
AssetController.combineJsFiles
validation
public function combineJsFiles($inputFiles, $outputFile) { $content = ''; foreach ($inputFiles as $file) { // Add a semicolon to source code if trailing semicolon missing. // Notice: It needs a new line before `;` to avoid affection of line comment. (// ...;) $fileContent = rtrim(file_get_contents($file)); if (substr($fileContent, -1) !== ';') { $fileContent .= "\n;"; } $content .= "/*** BEGIN FILE: $file ***/\n" . $fileContent . "\n" . "/*** END FILE: $file ***/\n"; } if (!file_put_contents($outputFile, $content)) { throw new Exception("Unable to write output JavaScript file '{$outputFile}'."); } }
php
{ "resource": "" }
q241834
AssetController.combineCssFiles
validation
public function combineCssFiles($inputFiles, $outputFile) { $content = ''; $outputFilePath = dirname($this->findRealPath($outputFile)); foreach ($inputFiles as $file) { $content .= "/*** BEGIN FILE: $file ***/\n" . $this->adjustCssUrl(file_get_contents($file), dirname($this->findRealPath($file)), $outputFilePath) . "/*** END FILE: $file ***/\n"; } if (!file_put_contents($outputFile, $content)) { throw new Exception("Unable to write output CSS file '{$outputFile}'."); } }
php
{ "resource": "" }
q241835
AssetController.composeCircularDependencyTrace
validation
private function composeCircularDependencyTrace($circularDependencyName, array $registered) { $dependencyTrace = []; $startFound = false; foreach ($registered as $name => $value) { if ($name === $circularDependencyName) { $startFound = true; } if ($startFound && $value === false) { $dependencyTrace[] = $name; } } $dependencyTrace[] = $circularDependencyName; return implode(' -> ', $dependencyTrace); }
php
{ "resource": "" }
q241836
AssetController.deletePublishedAssets
validation
private function deletePublishedAssets($bundles) { $this->stdout("Deleting source files...\n"); if ($this->getAssetManager()->linkAssets) { $this->stdout("`AssetManager::linkAssets` option is enabled. Deleting of source files canceled.\n", Console::FG_YELLOW); return; } foreach ($bundles as $bundle) { if ($bundle->sourcePath !== null) { foreach ($bundle->js as $jsFile) { @unlink($bundle->basePath . DIRECTORY_SEPARATOR . $jsFile); } foreach ($bundle->css as $cssFile) { @unlink($bundle->basePath . DIRECTORY_SEPARATOR . $cssFile); } } } $this->stdout("Source files deleted.\n", Console::FG_GREEN); }
php
{ "resource": "" }
q241837
Utf8Controller.actionCheckGuide
validation
public function actionCheckGuide($directory = null) { if ($directory === null) { $directory = \dirname(\dirname(__DIR__)) . '/docs'; } if (is_file($directory)) { $files = [$directory]; } else { $files = FileHelper::findFiles($directory, [ 'only' => ['*.md'], ]); } foreach ($files as $file) { $content = file_get_contents($file); $chars = preg_split('//u', $content, null, PREG_SPLIT_NO_EMPTY); $line = 1; $pos = 0; foreach ($chars as $c) { $ord = $this->unicodeOrd($c); $pos++; if ($ord == 0x000A) { $line++; $pos = 0; } if ($ord === false) { $this->found('BROKEN UTF8', $c, $line, $pos, $file); continue; } // http://unicode-table.com/en/blocks/general-punctuation/ if (0x2000 <= $ord && $ord <= 0x200F || 0x2028 <= $ord && $ord <= 0x202E || 0x205f <= $ord && $ord <= 0x206F ) { $this->found('UNSUPPORTED SPACE CHARACTER', $c, $line, $pos, $file); continue; } if ($ord < 0x0020 && $ord != 0x000A && $ord != 0x0009 || 0x0080 <= $ord && $ord < 0x009F) { $this->found('CONTROL CHARARCTER', $c, $line, $pos, $file); continue; } // if ($ord > 0x009F) { // $this->found("NON ASCII CHARARCTER", $c, $line, $pos, $file); // continue; // } } } }
php
{ "resource": "" }
q241838
ActiveQuery.one
validation
public function one($db = null) { $row = parent::one($db); if ($row !== false) { $models = $this->populate([$row]); return reset($models) ?: null; } return null; }
php
{ "resource": "" }
q241839
ActiveQuery.joinWith
validation
public function joinWith($with, $eagerLoading = true, $joinType = 'LEFT JOIN') { $relations = []; foreach ((array) $with as $name => $callback) { if (is_int($name)) { $name = $callback; $callback = null; } if (preg_match('/^(.*?)(?:\s+AS\s+|\s+)(\w+)$/i', $name, $matches)) { // relation is defined with an alias, adjust callback to apply alias list(, $relation, $alias) = $matches; $name = $relation; $callback = function ($query) use ($callback, $alias) { /* @var $query ActiveQuery */ $query->alias($alias); if ($callback !== null) { call_user_func($callback, $query); } }; } if ($callback === null) { $relations[] = $name; } else { $relations[$name] = $callback; } } $this->joinWith[] = [$relations, $eagerLoading, $joinType]; return $this; }
php
{ "resource": "" }
q241840
ActiveQuery.joinWithRelation
validation
private function joinWithRelation($parent, $child, $joinType) { $via = $child->via; $child->via = null; if ($via instanceof self) { // via table $this->joinWithRelation($parent, $via, $joinType); $this->joinWithRelation($via, $child, $joinType); return; } elseif (is_array($via)) { // via relation $this->joinWithRelation($parent, $via[1], $joinType); $this->joinWithRelation($via[1], $child, $joinType); return; } list($parentTable, $parentAlias) = $parent->getTableNameAndAlias(); list($childTable, $childAlias) = $child->getTableNameAndAlias(); if (!empty($child->link)) { if (strpos($parentAlias, '{{') === false) { $parentAlias = '{{' . $parentAlias . '}}'; } if (strpos($childAlias, '{{') === false) { $childAlias = '{{' . $childAlias . '}}'; } $on = []; foreach ($child->link as $childColumn => $parentColumn) { $on[] = "$parentAlias.[[$parentColumn]] = $childAlias.[[$childColumn]]"; } $on = implode(' AND ', $on); if (!empty($child->on)) { $on = ['and', $on, $child->on]; } } else { $on = $child->on; } $this->join($joinType, empty($child->from) ? $childTable : $child->from, $on); if (!empty($child->where)) { $this->andWhere($child->where); } if (!empty($child->having)) { $this->andHaving($child->having); } if (!empty($child->orderBy)) { $this->addOrderBy($child->orderBy); } if (!empty($child->groupBy)) { $this->addGroupBy($child->groupBy); } if (!empty($child->params)) { $this->addParams($child->params); } if (!empty($child->join)) { foreach ($child->join as $join) { $this->join[] = $join; } } if (!empty($child->union)) { foreach ($child->union as $union) { $this->union[] = $union; } } }
php
{ "resource": "" }
q241841
ActiveQuery.andOnCondition
validation
public function andOnCondition($condition, $params = []) { if ($this->on === null) { $this->on = $condition; } else { $this->on = ['and', $this->on, $condition]; } $this->addParams($params); return $this; }
php
{ "resource": "" }
q241842
ActiveQuery.orOnCondition
validation
public function orOnCondition($condition, $params = []) { if ($this->on === null) { $this->on = $condition; } else { $this->on = ['or', $this->on, $condition]; } $this->addParams($params); return $this; }
php
{ "resource": "" }
q241843
SqlTokenizer.tokenize
validation
public function tokenize() { $this->length = mb_strlen($this->sql, 'UTF-8'); $this->offset = 0; $this->_substrings = []; $this->_buffer = ''; $this->_token = new SqlToken([ 'type' => SqlToken::TYPE_CODE, 'content' => $this->sql, ]); $this->_tokenStack = new \SplStack(); $this->_tokenStack->push($this->_token); $this->_token[] = new SqlToken(['type' => SqlToken::TYPE_STATEMENT]); $this->_tokenStack->push($this->_token[0]); $this->_currentToken = $this->_tokenStack->top(); while (!$this->isEof()) { if ($this->isWhitespace($length) || $this->isComment($length)) { $this->addTokenFromBuffer(); $this->advance($length); continue; } if ($this->tokenizeOperator($length) || $this->tokenizeDelimitedString($length)) { $this->advance($length); continue; } $this->_buffer .= $this->substring(1); $this->advance(1); } $this->addTokenFromBuffer(); if ($this->_token->getHasChildren() && !$this->_token[-1]->getHasChildren()) { unset($this->_token[-1]); } return $this->_token; }
php
{ "resource": "" }
q241844
SqlTokenizer.startsWithAnyLongest
validation
protected function startsWithAnyLongest(array &$with, $caseSensitive, &$length = null, &$content = null) { if (empty($with)) { return false; } if (!is_array(reset($with))) { usort($with, function ($string1, $string2) { return mb_strlen($string2, 'UTF-8') - mb_strlen($string1, 'UTF-8'); }); $map = []; foreach ($with as $string) { $map[mb_strlen($string, 'UTF-8')][$caseSensitive ? $string : mb_strtoupper($string, 'UTF-8')] = true; } $with = $map; } foreach ($with as $testLength => $testValues) { $content = $this->substring($testLength, $caseSensitive); if (isset($testValues[$content])) { $length = $testLength; return true; } } return false; }
php
{ "resource": "" }
q241845
SqlTokenizer.substring
validation
protected function substring($length, $caseSensitive = true, $offset = null) { if ($offset === null) { $offset = $this->offset; } if ($offset + $length > $this->length) { return ''; } $cacheKey = $offset . ',' . $length; if (!isset($this->_substrings[$cacheKey . ',1'])) { $this->_substrings[$cacheKey . ',1'] = mb_substr($this->sql, $offset, $length, 'UTF-8'); } if (!$caseSensitive && !isset($this->_substrings[$cacheKey . ',0'])) { $this->_substrings[$cacheKey . ',0'] = mb_strtoupper($this->_substrings[$cacheKey . ',1'], 'UTF-8'); } return $this->_substrings[$cacheKey . ',' . (int) $caseSensitive]; }
php
{ "resource": "" }
q241846
SqlTokenizer.indexAfter
validation
protected function indexAfter($string, $offset = null) { if ($offset === null) { $offset = $this->offset; } if ($offset + mb_strlen($string, 'UTF-8') > $this->length) { return $this->length; } $afterIndexOf = mb_strpos($this->sql, $string, $offset, 'UTF-8'); if ($afterIndexOf === false) { $afterIndexOf = $this->length; } else { $afterIndexOf += mb_strlen($string, 'UTF-8'); } return $afterIndexOf; }
php
{ "resource": "" }
q241847
SqlTokenizer.tokenizeDelimitedString
validation
private function tokenizeDelimitedString(&$length) { $isIdentifier = $this->isIdentifier($length, $content); $isStringLiteral = !$isIdentifier && $this->isStringLiteral($length, $content); if (!$isIdentifier && !$isStringLiteral) { return false; } $this->addTokenFromBuffer(); $this->_currentToken[] = new SqlToken([ 'type' => $isIdentifier ? SqlToken::TYPE_IDENTIFIER : SqlToken::TYPE_STRING_LITERAL, 'content' => is_string($content) ? $content : $this->substring($length), 'startOffset' => $this->offset, 'endOffset' => $this->offset + $length, ]); return true; }
php
{ "resource": "" }
q241848
SqlTokenizer.tokenizeOperator
validation
private function tokenizeOperator(&$length) { if (!$this->isOperator($length, $content)) { return false; } $this->addTokenFromBuffer(); switch ($this->substring($length)) { case '(': $this->_currentToken[] = new SqlToken([ 'type' => SqlToken::TYPE_OPERATOR, 'content' => is_string($content) ? $content : $this->substring($length), 'startOffset' => $this->offset, 'endOffset' => $this->offset + $length, ]); $this->_currentToken[] = new SqlToken(['type' => SqlToken::TYPE_PARENTHESIS]); $this->_tokenStack->push($this->_currentToken[-1]); $this->_currentToken = $this->_tokenStack->top(); break; case ')': $this->_tokenStack->pop(); $this->_currentToken = $this->_tokenStack->top(); $this->_currentToken[] = new SqlToken([ 'type' => SqlToken::TYPE_OPERATOR, 'content' => ')', 'startOffset' => $this->offset, 'endOffset' => $this->offset + $length, ]); break; case ';': if (!$this->_currentToken->getHasChildren()) { break; } $this->_currentToken[] = new SqlToken([ 'type' => SqlToken::TYPE_OPERATOR, 'content' => is_string($content) ? $content : $this->substring($length), 'startOffset' => $this->offset, 'endOffset' => $this->offset + $length, ]); $this->_tokenStack->pop(); $this->_currentToken = $this->_tokenStack->top(); $this->_currentToken[] = new SqlToken(['type' => SqlToken::TYPE_STATEMENT]); $this->_tokenStack->push($this->_currentToken[-1]); $this->_currentToken = $this->_tokenStack->top(); break; default: $this->_currentToken[] = new SqlToken([ 'type' => SqlToken::TYPE_OPERATOR, 'content' => is_string($content) ? $content : $this->substring($length), 'startOffset' => $this->offset, 'endOffset' => $this->offset + $length, ]); break; } return true; }
php
{ "resource": "" }
q241849
SqlTokenizer.addTokenFromBuffer
validation
private function addTokenFromBuffer() { if ($this->_buffer === '') { return; } $isKeyword = $this->isKeyword($this->_buffer, $content); $this->_currentToken[] = new SqlToken([ 'type' => $isKeyword ? SqlToken::TYPE_KEYWORD : SqlToken::TYPE_TOKEN, 'content' => is_string($content) ? $content : $this->_buffer, 'startOffset' => $this->offset - mb_strlen($this->_buffer, 'UTF-8'), 'endOffset' => $this->offset, ]); $this->_buffer = ''; }
php
{ "resource": "" }
q241850
AssetConverter.convert
validation
public function convert($asset, $basePath) { $pos = strrpos($asset, '.'); if ($pos !== false) { $ext = substr($asset, $pos + 1); if (isset($this->commands[$ext])) { list($ext, $command) = $this->commands[$ext]; $result = substr($asset, 0, $pos + 1) . $ext; if ($this->forceConvert || @filemtime("$basePath/$result") < @filemtime("$basePath/$asset")) { $this->runCommand($command, $basePath, $asset, $result); } return $result; } } return $asset; }
php
{ "resource": "" }
q241851
Container.get
validation
public function get($class, $params = [], $config = []) { if (isset($this->_singletons[$class])) { // singleton return $this->_singletons[$class]; } elseif (!isset($this->_definitions[$class])) { return $this->build($class, $params, $config); } $definition = $this->_definitions[$class]; if (is_callable($definition, true)) { $params = $this->resolveDependencies($this->mergeParams($class, $params)); $object = call_user_func($definition, $this, $params, $config); } elseif (is_array($definition)) { $concrete = $definition['class']; unset($definition['class']); $config = array_merge($definition, $config); $params = $this->mergeParams($class, $params); if ($concrete === $class) { $object = $this->build($class, $params, $config); } else { $object = $this->get($concrete, $params, $config); } } elseif (is_object($definition)) { return $this->_singletons[$class] = $definition; } else { throw new InvalidConfigException('Unexpected object definition type: ' . gettype($definition)); } if (array_key_exists($class, $this->_singletons)) { // singleton $this->_singletons[$class] = $object; } return $object; }
php
{ "resource": "" }
q241852
Container.set
validation
public function set($class, $definition = [], array $params = []) { $this->_definitions[$class] = $this->normalizeDefinition($class, $definition); $this->_params[$class] = $params; unset($this->_singletons[$class]); return $this; }
php
{ "resource": "" }
q241853
Container.setSingleton
validation
public function setSingleton($class, $definition = [], array $params = []) { $this->_definitions[$class] = $this->normalizeDefinition($class, $definition); $this->_params[$class] = $params; $this->_singletons[$class] = null; return $this; }
php
{ "resource": "" }
q241854
Container.build
validation
protected function build($class, $params, $config) { /* @var $reflection ReflectionClass */ list($reflection, $dependencies) = $this->getDependencies($class); foreach ($params as $index => $param) { $dependencies[$index] = $param; } $dependencies = $this->resolveDependencies($dependencies, $reflection); if (!$reflection->isInstantiable()) { throw new NotInstantiableException($reflection->name); } if (empty($config)) { return $reflection->newInstanceArgs($dependencies); } $config = $this->resolveDependencies($config); if (!empty($dependencies) && $reflection->implementsInterface('yii\base\Configurable')) { // set $config as the last parameter (existing one will be overwritten) $dependencies[count($dependencies) - 1] = $config; return $reflection->newInstanceArgs($dependencies); } $object = $reflection->newInstanceArgs($dependencies); foreach ($config as $name => $value) { $object->$name = $value; } return $object; }
php
{ "resource": "" }
q241855
Container.getDependencies
validation
protected function getDependencies($class) { if (isset($this->_reflections[$class])) { return [$this->_reflections[$class], $this->_dependencies[$class]]; } $dependencies = []; try { $reflection = new ReflectionClass($class); } catch (\ReflectionException $e) { throw new InvalidConfigException('Failed to instantiate component or class "' . $class . '".', 0, $e); } $constructor = $reflection->getConstructor(); if ($constructor !== null) { foreach ($constructor->getParameters() as $param) { if (version_compare(PHP_VERSION, '5.6.0', '>=') && $param->isVariadic()) { break; } elseif ($param->isDefaultValueAvailable()) { $dependencies[] = $param->getDefaultValue(); } else { $c = $param->getClass(); $dependencies[] = Instance::of($c === null ? null : $c->getName()); } } } $this->_reflections[$class] = $reflection; $this->_dependencies[$class] = $dependencies; return [$reflection, $dependencies]; }
php
{ "resource": "" }
q241856
Container.resolveDependencies
validation
protected function resolveDependencies($dependencies, $reflection = null) { foreach ($dependencies as $index => $dependency) { if ($dependency instanceof Instance) { if ($dependency->id !== null) { $dependencies[$index] = $this->get($dependency->id); } elseif ($reflection !== null) { $name = $reflection->getConstructor()->getParameters()[$index]->getName(); $class = $reflection->getName(); throw new InvalidConfigException("Missing required parameter \"$name\" when instantiating \"$class\"."); } } } return $dependencies; }
php
{ "resource": "" }
q241857
Container.setDefinitions
validation
public function setDefinitions(array $definitions) { foreach ($definitions as $class => $definition) { if (is_array($definition) && count($definition) === 2 && array_values($definition) === $definition) { $this->set($class, $definition[0], $definition[1]); continue; } $this->set($class, $definition); } }
php
{ "resource": "" }
q241858
ArrayParser.parseArray
validation
private function parseArray($value, &$i = 0) { $result = []; $len = strlen($value); for (++$i; $i < $len; ++$i) { switch ($value[$i]) { case '{': $result[] = $this->parseArray($value, $i); break; case '}': break 2; case $this->delimiter: if (empty($result)) { // `{}` case $result[] = null; } if (in_array($value[$i + 1], [$this->delimiter, '}'], true)) { // `{,}` case $result[] = null; } break; default: $result[] = $this->parseString($value, $i); } } return $result; }
php
{ "resource": "" }
q241859
ArrayParser.parseString
validation
private function parseString($value, &$i) { $isQuoted = $value[$i] === '"'; $stringEndChars = $isQuoted ? ['"'] : [$this->delimiter, '}']; $result = ''; $len = strlen($value); for ($i += $isQuoted ? 1 : 0; $i < $len; ++$i) { if (in_array($value[$i], ['\\', '"'], true) && in_array($value[$i + 1], [$value[$i], '"'], true)) { ++$i; } elseif (in_array($value[$i], $stringEndChars, true)) { break; } $result .= $value[$i]; } $i -= $isQuoted ? 0 : 1; if (!$isQuoted && $result === 'NULL') { $result = null; } return $result; }
php
{ "resource": "" }
q241860
DynamicModel.validateData
validation
public static function validateData(array $data, $rules = []) { /* @var $model DynamicModel */ $model = new static($data); if (!empty($rules)) { $validators = $model->getValidators(); foreach ($rules as $rule) { if ($rule instanceof Validator) { $validators->append($rule); } elseif (is_array($rule) && isset($rule[0], $rule[1])) { // attributes, validator type $validator = Validator::createValidator($rule[1], $model, (array)$rule[0], array_slice($rule, 2)); $validators->append($validator); } else { throw new InvalidConfigException('Invalid validation rule: a rule must specify both attribute names and validator type.'); } } } $model->validate(); return $model; }
php
{ "resource": "" }
q241861
DbQueryDependency.generateDependencyData
validation
protected function generateDependencyData($cache) { $db = $this->db; if ($db !== null) { $db = Instance::ensure($db); } if (!$this->query instanceof QueryInterface) { throw new InvalidConfigException('"' . get_class($this) . '::$query" should be an instance of "yii\db\QueryInterface".'); } if (!empty($db->enableQueryCache)) { // temporarily disable and re-enable query caching $originEnableQueryCache = $db->enableQueryCache; $db->enableQueryCache = false; $result = $this->executeQuery($this->query, $db); $db->enableQueryCache = $originEnableQueryCache; } else { $result = $this->executeQuery($this->query, $db); } return $result; }
php
{ "resource": "" }
q241862
InConditionBuilder.splitCondition
validation
protected function splitCondition(InCondition $condition, &$params) { $operator = $condition->getOperator(); $values = $condition->getValues(); $column = $condition->getColumn(); if ($values instanceof \Traversable) { $values = iterator_to_array($values); } if (!is_array($values)) { return null; } $maxParameters = 1000; $count = count($values); if ($count <= $maxParameters) { return null; } $slices = []; for ($i = 0; $i < $count; $i += $maxParameters) { $slices[] = $this->queryBuilder->createConditionFromArray([$operator, $column, array_slice($values, $i, $maxParameters)]); } array_unshift($slices, ($operator === 'IN') ? 'OR' : 'AND'); return $this->queryBuilder->buildCondition($slices, $params); }
php
{ "resource": "" }
q241863
ActiveQueryTrait.with
validation
public function with() { $with = func_get_args(); if (isset($with[0]) && is_array($with[0])) { // the parameter is given as an array $with = $with[0]; } if (empty($this->with)) { $this->with = $with; } elseif (!empty($with)) { foreach ($with as $name => $value) { if (is_int($name)) { // repeating relation is fine as normalizeRelations() handle it well $this->with[] = $value; } else { $this->with[$name] = $value; } } } return $this; }
php
{ "resource": "" }
q241864
ActiveQueryTrait.createModels
validation
protected function createModels($rows) { if ($this->asArray) { return $rows; } else { $models = []; /* @var $class ActiveRecord */ $class = $this->modelClass; foreach ($rows as $row) { $model = $class::instantiate($row); $modelClass = get_class($model); $modelClass::populateRecord($model, $row); $models[] = $model; } return $models; } }
php
{ "resource": "" }
q241865
ActiveQueryTrait.findWith
validation
public function findWith($with, &$models) { $primaryModel = reset($models); if (!$primaryModel instanceof ActiveRecordInterface) { /* @var $modelClass ActiveRecordInterface */ $modelClass = $this->modelClass; $primaryModel = $modelClass::instance(); } $relations = $this->normalizeRelations($primaryModel, $with); /* @var $relation ActiveQuery */ foreach ($relations as $name => $relation) { if ($relation->asArray === null) { // inherit asArray from primary query $relation->asArray($this->asArray); } $relation->populateRelation($name, $models); } }
php
{ "resource": "" }
q241866
ErrorHandler.handleHhvmError
validation
public function handleHhvmError($code, $message, $file, $line, $context, $backtrace) { if ($this->handleError($code, $message, $file, $line)) { return true; } if (E_ERROR & $code) { $exception = new ErrorException($message, $code, $code, $file, $line); $ref = new \ReflectionProperty('\Exception', 'trace'); $ref->setAccessible(true); $ref->setValue($exception, $backtrace); $this->_hhvmException = $exception; } return false; }
php
{ "resource": "" }
q241867
Command.cache
validation
public function cache($duration = null, $dependency = null) { $this->queryCacheDuration = $duration === null ? $this->db->queryCacheDuration : $duration; $this->queryCacheDependency = $dependency; return $this; }
php
{ "resource": "" }
q241868
Command.bindParam
validation
public function bindParam($name, &$value, $dataType = null, $length = null, $driverOptions = null) { $this->prepare(); if ($dataType === null) { $dataType = $this->db->getSchema()->getPdoType($value); } if ($length === null) { $this->pdoStatement->bindParam($name, $value, $dataType); } elseif ($driverOptions === null) { $this->pdoStatement->bindParam($name, $value, $dataType, $length); } else { $this->pdoStatement->bindParam($name, $value, $dataType, $length, $driverOptions); } $this->params[$name] = &$value; return $this; }
php
{ "resource": "" }
q241869
Command.bindValue
validation
public function bindValue($name, $value, $dataType = null) { if ($dataType === null) { $dataType = $this->db->getSchema()->getPdoType($value); } $this->_pendingParams[$name] = [$value, $dataType]; $this->params[$name] = $value; return $this; }
php
{ "resource": "" }
q241870
Command.queryScalar
validation
public function queryScalar() { $result = $this->queryInternal('fetchColumn', 0); if (is_resource($result) && get_resource_type($result) === 'stream') { return stream_get_contents($result); } return $result; }
php
{ "resource": "" }
q241871
Command.insert
validation
public function insert($table, $columns) { $params = []; $sql = $this->db->getQueryBuilder()->insert($table, $columns, $params); return $this->setSql($sql)->bindValues($params); }
php
{ "resource": "" }
q241872
Command.batchInsert
validation
public function batchInsert($table, $columns, $rows) { $table = $this->db->quoteSql($table); $columns = array_map(function ($column) { return $this->db->quoteSql($column); }, $columns); $params = []; $sql = $this->db->getQueryBuilder()->batchInsert($table, $columns, $rows, $params); $this->setRawSql($sql); $this->bindValues($params); return $this; }
php
{ "resource": "" }
q241873
Command.update
validation
public function update($table, $columns, $condition = '', $params = []) { $sql = $this->db->getQueryBuilder()->update($table, $columns, $condition, $params); return $this->setSql($sql)->bindValues($params); }
php
{ "resource": "" }
q241874
Command.delete
validation
public function delete($table, $condition = '', $params = []) { $sql = $this->db->getQueryBuilder()->delete($table, $condition, $params); return $this->setSql($sql)->bindValues($params); }
php
{ "resource": "" }
q241875
Command.createTable
validation
public function createTable($table, $columns, $options = null) { $sql = $this->db->getQueryBuilder()->createTable($table, $columns, $options); return $this->setSql($sql)->requireTableSchemaRefresh($table); }
php
{ "resource": "" }
q241876
Command.renameTable
validation
public function renameTable($table, $newName) { $sql = $this->db->getQueryBuilder()->renameTable($table, $newName); return $this->setSql($sql)->requireTableSchemaRefresh($table); }
php
{ "resource": "" }
q241877
Command.dropTable
validation
public function dropTable($table) { $sql = $this->db->getQueryBuilder()->dropTable($table); return $this->setSql($sql)->requireTableSchemaRefresh($table); }
php
{ "resource": "" }
q241878
Command.truncateTable
validation
public function truncateTable($table) { $sql = $this->db->getQueryBuilder()->truncateTable($table); return $this->setSql($sql); }
php
{ "resource": "" }
q241879
Command.addColumn
validation
public function addColumn($table, $column, $type) { $sql = $this->db->getQueryBuilder()->addColumn($table, $column, $type); return $this->setSql($sql)->requireTableSchemaRefresh($table); }
php
{ "resource": "" }
q241880
Command.renameColumn
validation
public function renameColumn($table, $oldName, $newName) { $sql = $this->db->getQueryBuilder()->renameColumn($table, $oldName, $newName); return $this->setSql($sql)->requireTableSchemaRefresh($table); }
php
{ "resource": "" }
q241881
Command.dropPrimaryKey
validation
public function dropPrimaryKey($name, $table) { $sql = $this->db->getQueryBuilder()->dropPrimaryKey($name, $table); return $this->setSql($sql)->requireTableSchemaRefresh($table); }
php
{ "resource": "" }
q241882
Command.addForeignKey
validation
public function addForeignKey($name, $table, $columns, $refTable, $refColumns, $delete = null, $update = null) { $sql = $this->db->getQueryBuilder()->addForeignKey($name, $table, $columns, $refTable, $refColumns, $delete, $update); return $this->setSql($sql)->requireTableSchemaRefresh($table); }
php
{ "resource": "" }
q241883
Command.createIndex
validation
public function createIndex($name, $table, $columns, $unique = false) { $sql = $this->db->getQueryBuilder()->createIndex($name, $table, $columns, $unique); return $this->setSql($sql)->requireTableSchemaRefresh($table); }
php
{ "resource": "" }
q241884
Command.addUnique
validation
public function addUnique($name, $table, $columns) { $sql = $this->db->getQueryBuilder()->addUnique($name, $table, $columns); return $this->setSql($sql)->requireTableSchemaRefresh($table); }
php
{ "resource": "" }
q241885
Command.addDefaultValue
validation
public function addDefaultValue($name, $table, $column, $value) { $sql = $this->db->getQueryBuilder()->addDefaultValue($name, $table, $column, $value); return $this->setSql($sql)->requireTableSchemaRefresh($table); }
php
{ "resource": "" }
q241886
Command.resetSequence
validation
public function resetSequence($table, $value = null) { $sql = $this->db->getQueryBuilder()->resetSequence($table, $value); return $this->setSql($sql); }
php
{ "resource": "" }
q241887
Command.checkIntegrity
validation
public function checkIntegrity($check = true, $schema = '', $table = '') { $sql = $this->db->getQueryBuilder()->checkIntegrity($check, $schema, $table); return $this->setSql($sql); }
php
{ "resource": "" }
q241888
Command.addCommentOnColumn
validation
public function addCommentOnColumn($table, $column, $comment) { $sql = $this->db->getQueryBuilder()->addCommentOnColumn($table, $column, $comment); return $this->setSql($sql)->requireTableSchemaRefresh($table); }
php
{ "resource": "" }
q241889
Command.addCommentOnTable
validation
public function addCommentOnTable($table, $comment) { $sql = $this->db->getQueryBuilder()->addCommentOnTable($table, $comment); return $this->setSql($sql); }
php
{ "resource": "" }
q241890
Command.dropCommentFromColumn
validation
public function dropCommentFromColumn($table, $column) { $sql = $this->db->getQueryBuilder()->dropCommentFromColumn($table, $column); return $this->setSql($sql)->requireTableSchemaRefresh($table); }
php
{ "resource": "" }
q241891
Command.dropCommentFromTable
validation
public function dropCommentFromTable($table) { $sql = $this->db->getQueryBuilder()->dropCommentFromTable($table); return $this->setSql($sql); }
php
{ "resource": "" }
q241892
Command.dropView
validation
public function dropView($viewName) { $sql = $this->db->getQueryBuilder()->dropView($viewName); return $this->setSql($sql)->requireTableSchemaRefresh($viewName); }
php
{ "resource": "" }
q241893
Command.execute
validation
public function execute() { $sql = $this->getSql(); list($profile, $rawSql) = $this->logQuery(__METHOD__); if ($sql == '') { return 0; } $this->prepare(false); try { $profile and Yii::beginProfile($rawSql, __METHOD__); $this->internalExecute($rawSql); $n = $this->pdoStatement->rowCount(); $profile and Yii::endProfile($rawSql, __METHOD__); $this->refreshTableSchema(); return $n; } catch (Exception $e) { $profile and Yii::endProfile($rawSql, __METHOD__); throw $e; } }
php
{ "resource": "" }
q241894
Command.getCacheKey
validation
protected function getCacheKey($method, $fetchMode, $rawSql) { return [ __CLASS__, $method, $fetchMode, $this->db->dsn, $this->db->username, $rawSql, ]; }
php
{ "resource": "" }
q241895
Command.internalExecute
validation
protected function internalExecute($rawSql) { $attempt = 0; while (true) { try { if ( ++$attempt === 1 && $this->_isolationLevel !== false && $this->db->getTransaction() === null ) { $this->db->transaction(function () use ($rawSql) { $this->internalExecute($rawSql); }, $this->_isolationLevel); } else { $this->pdoStatement->execute(); } break; } catch (\Exception $e) { $rawSql = $rawSql ?: $this->getRawSql(); $e = $this->db->getSchema()->convertException($e, $rawSql); if ($this->_retryHandler === null || !call_user_func($this->_retryHandler, $e, $attempt)) { throw $e; } } } }
php
{ "resource": "" }
q241896
Command.reset
validation
protected function reset() { $this->_sql = null; $this->_pendingParams = []; $this->params = []; $this->_refreshTableName = null; $this->_isolationLevel = false; $this->_retryHandler = null; }
php
{ "resource": "" }
q241897
Mutex.init
validation
public function init() { if ($this->autoRelease) { $locks = &$this->_locks; register_shutdown_function(function () use (&$locks) { foreach ($locks as $lock) { $this->release($lock); } }); } }
php
{ "resource": "" }
q241898
Mutex.release
validation
public function release($name) { if ($this->releaseLock($name)) { $index = array_search($name, $this->_locks); if ($index !== false) { unset($this->_locks[$index]); } return true; } return false; }
php
{ "resource": "" }
q241899
Connection.cache
validation
public function cache(callable $callable, $duration = null, $dependency = null) { $this->_queryCacheInfo[] = [$duration === null ? $this->queryCacheDuration : $duration, $dependency]; try { $result = call_user_func($callable, $this); array_pop($this->_queryCacheInfo); return $result; } catch (\Exception $e) { array_pop($this->_queryCacheInfo); throw $e; } catch (\Throwable $e) { array_pop($this->_queryCacheInfo); throw $e; } }
php
{ "resource": "" }