_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 33 8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q19200 | Swift_Mime_MimePart.fixHeaders | train | protected function fixHeaders()
{
parent::fixHeaders();
if (count($this->getChildren())) {
$this->setHeaderParameter('Content-Type', 'charset', null);
$this->setHeaderParameter('Content-Type', 'format', null);
$this->setHeaderParameter('Content-Type', 'delsp', nul... | php | {
"resource": ""
} |
q19201 | Swift_Mime_MimePart.convertString | train | protected function convertString($string)
{
$charset = strtolower($this->getCharset());
if (!in_array($charset, ['utf-8', 'iso-8859-1', 'iso-8859-15', ''])) {
return | php | {
"resource": ""
} |
q19202 | CHttpCacheFilter.sendCacheControlHeader | train | protected function sendCacheControlHeader()
{
if(Yii::app()->session->isStarted)
{
Yii::app()->session->setCacheLimiter('public');
| php | {
"resource": ""
} |
q19203 | CViewRenderer.getViewFile | train | protected function getViewFile($file)
{
if($this->useRuntimePath)
{
$crc=sprintf('%x', crc32(get_class($this).Yii::getVersion().dirname($file)));
$viewFile=Yii::app()->getRuntimePath().DIRECTORY_SEPARATOR.'views'.DIRECTORY_SEPARATOR.$crc.DIRECTORY_SEPARATOR.basename($file); | php | {
"resource": ""
} |
q19204 | CDbMigration.up | train | public function up()
{
$transaction=$this->getDbConnection()->beginTransaction();
try
{
if($this->safeUp()===false)
{
$transaction->rollback();
return false;
}
$transaction->commit();
}
catch(Exception $e)
| php | {
"resource": ""
} |
q19205 | CDbMigration.down | train | public function down()
{
$transaction=$this->getDbConnection()->beginTransaction();
try
{
if($this->safeDown()===false)
{
$transaction->rollback();
return false;
}
$transaction->commit();
}
catch(Exception | php | {
"resource": ""
} |
q19206 | CDbMigration.insert | train | public function insert($table, $columns)
{
echo " > insert into $table ...";
$time=microtime(true); | php | {
"resource": ""
} |
q19207 | CDbMigration.insertMultiple | train | public function insertMultiple($table, $data)
{
echo " > insert into $table ...";
$time=microtime(true);
$builder=$this->getDbConnection()->getSchema()->getCommandBuilder();
| php | {
"resource": ""
} |
q19208 | CDbMigration.update | train | public function update($table, $columns, $conditions='', $params=array())
{
echo " > update $table ...";
$time=microtime(true);
$this->getDbConnection()->createCommand()->update($table, $columns, | php | {
"resource": ""
} |
q19209 | CDbMigration.delete | train | public function delete($table, $conditions='', $params=array())
{
echo " > delete from $table ...";
$time=microtime(true); | php | {
"resource": ""
} |
q19210 | CDbMigration.createTable | train | public function createTable($table, $columns, $options=null)
{
echo " > create table $table ...";
$time=microtime(true); | php | {
"resource": ""
} |
q19211 | CDbMigration.renameTable | train | public function renameTable($table, $newName)
{
echo " > rename table $table to $newName ...";
$time=microtime(true); | php | {
"resource": ""
} |
q19212 | CDbMigration.dropColumn | train | public function dropColumn($table, $column)
{
echo " > drop column $column from table $table ...";
$time=microtime(true); | php | {
"resource": ""
} |
q19213 | CDbMigration.renameColumn | train | public function renameColumn($table, $name, $newName)
{
echo " > rename column $name in table $table to $newName ...";
$time=microtime(true);
| php | {
"resource": ""
} |
q19214 | CDbMigration.alterColumn | train | public function alterColumn($table, $column, $type)
{
echo " > alter column $column in table $table to $type ...";
$time=microtime(true);
| php | {
"resource": ""
} |
q19215 | CDbMigration.addForeignKey | train | public function addForeignKey($name, $table, $columns, $refTable, $refColumns, $delete=null, $update=null)
{
echo " > add foreign key $name: $table (".(is_array($columns) ? implode(',', $columns) : $columns).
") | php | {
"resource": ""
} |
q19216 | CDbMigration.dropForeignKey | train | public function dropForeignKey($name, $table)
{
echo " > drop foreign key $name from table $table ...";
$time=microtime(true);
| php | {
"resource": ""
} |
q19217 | CDbMigration.createIndex | train | public function createIndex($name, $table, $columns, $unique=false)
{
echo " > create".($unique ? ' unique':'')." index $name on $table (".(is_array($columns) ? implode(',', $columns) : $columns).") ...";
$time=microtime(true); | php | {
"resource": ""
} |
q19218 | CDbMigration.refreshTableSchema | train | public function refreshTableSchema($table)
{
echo " > refresh table $table schema cache ...";
$time=microtime(true);
| php | {
"resource": ""
} |
q19219 | CDbMigration.addPrimaryKey | train | public function addPrimaryKey($name,$table,$columns)
{
echo " > alter table $table add constraint $name primary key (".(is_array($columns) ? implode(',', $columns) : $columns).") ...";
$time=microtime(true);
| php | {
"resource": ""
} |
q19220 | CWidgetFactory.init | train | public function init()
{
parent::init();
if($this->enableSkin && $this->skinPath===null)
| php | {
"resource": ""
} |
q19221 | CButtonColumn.getDataCellContent | train | public function getDataCellContent($row)
{
$data=$this->grid->dataProvider->data[$row];
$tr=array();
ob_start();
foreach($this->buttons as $id=>$button)
{
$this->renderButton($id,$button,$row,$data); | php | {
"resource": ""
} |
q19222 | Post.addComment | train | public function addComment($comment)
{
if(Yii::app()->params['commentNeedApproval'])
$comment->status=Comment::STATUS_PENDING;
else
| php | {
"resource": ""
} |
q19223 | PostController.actionList | train | public function actionList()
{
$pages=new CPagination(Post::model()->count());
$postList=Post::model()->findAll($this->getListCriteria($pages)); | php | {
"resource": ""
} |
q19224 | PostController.actionCreate | train | public function actionCreate()
{
$post=new Post;
if(Yii::app()->request->isPostRequest)
{
if(isset($_POST['Post']))
$post->setAttributes($_POST['Post']);
if($post->save()) | php | {
"resource": ""
} |
q19225 | PostController.actionUpdate | train | public function actionUpdate()
{
$post=$this->loadPost();
if(Yii::app()->request->isPostRequest)
{
if(isset($_POST['Post']))
$post->setAttributes($_POST['Post']);
if($post->save()) | php | {
"resource": ""
} |
q19226 | PostController.actionDelete | train | public function actionDelete()
{
if(Yii::app()->request->isPostRequest)
{
// we only allow deletion via POST request
| php | {
"resource": ""
} |
q19227 | PostController.loadPost | train | protected function loadPost()
{
if(isset($_GET['id']))
$post=Post::model()->findbyPk($_GET['id']);
if(isset($post))
return $post;
| php | {
"resource": ""
} |
q19228 | PostController.generateColumnHeader | train | protected function generateColumnHeader($column)
{
$params=$_GET;
if(isset($params['sort']) && $params['sort']===$column)
{
if(isset($params['desc']))
unset($params['desc']);
else
$params['desc']=1;
}
else | php | {
"resource": ""
} |
q19229 | CStarRating.registerClientScript | train | public function registerClientScript($id)
{
$jsOptions=$this->getClientOptions();
$jsOptions=empty($jsOptions) ? '' : CJavaScript::encode($jsOptions);
$js="jQuery('#{$id} > input').rating({$jsOptions});";
$cs=Yii::app()->getClientScript();
$cs->registerCoreScript('rating');
| php | {
"resource": ""
} |
q19230 | CStarRating.renderStars | train | protected function renderStars($id,$name)
{
$inputCount=(int)(($this->maxRating-$this->minRating)/$this->ratingStepSize+1);
$starSplit=(int)($inputCount/$this->starCount);
if($this->hasModel())
{
$attr=$this->attribute;
CHtml::resolveName($this->model,$attr);
$selection=$this->model->$attr;
}
else... | php | {
"resource": ""
} |
q19231 | CListPager.generatePageText | train | protected function generatePageText($page)
{
if($this->pageTextFormat!==null)
return | php | {
"resource": ""
} |
q19232 | CFormElementCollection.remove | train | public function remove($key)
{
if(($item=parent::remove($key))!==null) | php | {
"resource": ""
} |
q19233 | CGridView.renderFilter | train | public function renderFilter()
{
if($this->filter!==null)
{
echo "<tr class=\"{$this->filterCssClass}\">\n";
foreach($this->columns | php | {
"resource": ""
} |
q19234 | GameController.actionPlay | train | public function actionPlay()
{
static $levels=array(
'10'=>'Easy game; you are allowed 10 misses.',
'5'=>'Medium game; you are allowed 5 misses.',
'3'=>'Hard game; you are allowed 3 misses.',
);
// if a difficulty level is correctly chosen
if(isset($_POST['level']) && isset($levels[$_POST['level']]))... | php | {
"resource": ""
} |
q19235 | GameController.actionGuess | train | public function actionGuess()
{
// check to see if the letter is guessed correctly
if(isset($_GET['g'][0]) && ($result=$this->guess($_GET['g'][0]))!==null)
$this->render($result ? 'win' : 'lose');
else // the letter is guessed correctly, but not win yet
| php | {
"resource": ""
} |
q19236 | GameController.generateWord | train | protected function generateWord()
{
$wordFile=dirname(__FILE__).'/words.txt';
$words=preg_split("/[\s,]+/",file_get_contents($wordFile));
do
{
| php | {
"resource": ""
} |
q19237 | GameController.guess | train | protected function guess($letter)
{
$word=$this->word;
$guessWord=$this->guessWord;
$pos=0;
$success=false;
while(($pos=strpos($word,$letter,$pos))!==false)
{
$guessWord[$pos]=$letter;
$success=true;
$pos++;
}
| php | {
"resource": ""
} |
q19238 | CConfiguration.loadFromFile | train | public function loadFromFile($configFile)
{
$data=require($configFile);
if($this->getCount()>0)
| php | {
"resource": ""
} |
q19239 | CJavaScript.quote | train | public static function quote($js,$forUrl=false)
{
$js = (string)$js;
Yii::import('system.vendors.zend-escaper.Escaper'); | php | {
"resource": ""
} |
q19240 | CJavaScript.encode | train | public static function encode($value,$safe=false)
{
if(is_string($value))
{
if(strpos($value,'js:')===0 && $safe===false)
return substr($value,3);
else
return "'".self::quote($value)."'";
}
elseif($value===null)
return 'null';
elseif(is_bool($value))
return $value?'true':'false';
elseif... | php | {
"resource": ""
} |
q19241 | CLogRouter.init | train | public function init()
{
parent::init();
foreach($this->_routes as $name=>$route)
{
$route=Yii::createComponent($route);
$route->init();
$this->_routes[$name]=$route;
}
| php | {
"resource": ""
} |
q19242 | YiiPearTask.main | train | function main()
{
$pkg = new PEAR_PackageFileManager2();
$e = $pkg->setOptions(array
(
'baseinstalldir' => 'yii',
'packagedirectory' => $this->pkgdir,
'filelistgenerator' => 'file',
'simpleoutput' => true,
'ignore' => array(),
'roles' => array('*' => 'php'),
)
);
//... | php | {
"resource": ""
} |
q19243 | CLocalizedFormatter.setLocale | train | public function setLocale($locale)
{
if(is_string($locale))
$locale=CLocale::getInstance($locale);
| php | {
"resource": ""
} |
q19244 | CCache.init | train | public function init()
{
parent::init();
if($this->keyPrefix===null) | php | {
"resource": ""
} |
q19245 | CCache.get | train | public function get($id)
{
$value = $this->getValue($this->generateUniqueKey($id));
if($value===false || $this->serializer===false)
return $value;
if($this->serializer===null)
$value=unserialize($value);
| php | {
"resource": ""
} |
q19246 | CCache.set | train | public function set($id,$value,$expire=0,$dependency=null)
{
Yii::trace('Saving "'.$id.'" to cache','system.caching.'.get_class($this));
if ($dependency !== null && $this->serializer !== false)
$dependency->evaluateDependency();
if ($this->serializer === null)
$value = serialize(array($value,$dependency)... | php | {
"resource": ""
} |
q19247 | CCache.delete | train | public function delete($id)
{
Yii::trace('Deleting "'.$id.'" from cache','system.caching.'.get_class($this)); | php | {
"resource": ""
} |
q19248 | CJuiWidget.resolvePackagePath | train | protected function resolvePackagePath()
{
if($this->scriptUrl===null || $this->themeUrl===null)
{
$cs=Yii::app()->getClientScript(); | php | {
"resource": ""
} |
q19249 | CJuiWidget.registerCoreScripts | train | protected function registerCoreScripts()
{
$cs=Yii::app()->getClientScript();
if(is_string($this->cssFile))
$cs->registerCssFile($this->themeUrl.'/'.$this->theme.'/'.$this->cssFile);
elseif(is_array($this->cssFile))
{
foreach($this->cssFile as $cssFile)
$cs->registerCssFile($this->themeUrl.'/'.$this-... | php | {
"resource": ""
} |
q19250 | CMarkdownParser._doCodeBlocks_callback | train | public function _doCodeBlocks_callback($matches)
{
$codeblock = $this->outdent($matches[1]);
if(($codeblock | php | {
"resource": ""
} |
q19251 | CMarkdownParser.highlightCodeBlock | train | protected function highlightCodeBlock($codeblock)
{
if(($tag=$this->getHighlightTag($codeblock))!==null && ($highlighter=$this->createHighLighter($tag)))
{
$codeblock = preg_replace('/\A\n+|\n+\z/', '', $codeblock);
$tagLen = | php | {
"resource": ""
} |
q19252 | CMarkdownParser.getHighlightTag | train | protected function getHighlightTag($codeblock)
{
$str = trim(current(preg_split("/\r|\n/", | php | {
"resource": ""
} |
q19253 | CMarkdownParser.createHighLighter | train | protected function createHighLighter($options)
{
if(!class_exists('Text_Highlighter', false))
{
require_once(Yii::getPathOfAlias('system.vendors.TextHighlighter.Text.Highlighter').'.php');
require_once(Yii::getPathOfAlias('system.vendors.TextHighlighter.Text.Highlighter.Renderer.Html').'.php');
}
$lang =... | php | {
"resource": ""
} |
q19254 | CMarkdownParser.getHighlightConfig | train | public function getHighlightConfig($options)
{
$config = array('use_language'=>true);
if( $this->getInlineOption('showLineNumbers', $options, false) )
$config['numbers'] = HL_NUMBERS_LI; | php | {
"resource": ""
} |
q19255 | CMarkdownParser.getInlineOption | train | protected function getInlineOption($name, $str, $defaultValue)
{
if(preg_match('/'.$name.'(\s*=\s*(\d+))?/i', | php | {
"resource": ""
} |
q19256 | CFileHelper.copyDirectory | train | public static function copyDirectory($src,$dst,$options=array())
{
$fileTypes=array();
$exclude=array();
$level=-1;
extract($options);
if(!is_dir($dst))
| php | {
"resource": ""
} |
q19257 | CFileHelper.findFiles | train | public static function findFiles($dir,$options=array())
{
$fileTypes=array();
$exclude=array();
$level=-1; | php | {
"resource": ""
} |
q19258 | CFileHelper.validatePath | train | protected static function validatePath($base,$file,$isFile,$fileTypes,$exclude)
{
foreach($exclude as $e)
{
if($file===$e || strpos($base.'/'.$file,$e)===0)
return false;
}
if(!$isFile || empty($fileTypes))
return | php | {
"resource": ""
} |
q19259 | CFileHelper.getMimeTypeByExtension | train | public static function getMimeTypeByExtension($file,$magicFile=null)
{
static $extensions,$customExtensions=array();
if($magicFile===null && $extensions===null)
$extensions=require(Yii::getPathOfAlias('system.utils.mimeTypes').'.php');
elseif($magicFile!==null && !isset($customExtensions[$magicFile]))
$cus... | php | {
"resource": ""
} |
q19260 | CFileHelper.getExtensionByMimeType | train | public static function getExtensionByMimeType($file,$magicFile=null)
{
static $mimeTypes,$customMimeTypes=array();
if($magicFile===null && $mimeTypes===null)
$mimeTypes=require(Yii::getPathOfAlias('system.utils.fileExtensions').'.php');
elseif($magicFile!==null && !isset($customMimeTypes[$magicFile]))
$cus... | php | {
"resource": ""
} |
q19261 | COutputProcessor.processOutput | train | public function processOutput($output)
{
if($this->hasEventHandler('onProcessOutput'))
{
$event=new COutputEvent($this,$output);
| php | {
"resource": ""
} |
q19262 | CSort.link | train | public function link($attribute,$label=null,$htmlOptions=array())
{
if($label===null)
$label=$this->resolveLabel($attribute);
if(($definition=$this->resolveAttribute($attribute))===false)
return $label;
$directions=$this->getDirections();
if(isset($directions[$attribute]))
{
$class=$directions[$attr... | php | {
"resource": ""
} |
q19263 | CSort.getDirections | train | public function getDirections()
{
if($this->_directions===null)
{
$this->_directions=array();
if(isset($_GET[$this->sortVar]) && is_string($_GET[$this->sortVar]))
{
$attributes=explode($this->separators[0],$_GET[$this->sortVar]);
foreach($attributes as $attribute)
{
if(($pos=strrpos($attr... | php | {
"resource": ""
} |
q19264 | CSort.getDirection | train | public function getDirection($attribute)
{
$this->getDirections(); | php | {
"resource": ""
} |
q19265 | CSort.createUrl | train | public function createUrl($controller,$directions)
{
$sorts=array();
foreach($directions as $attribute=>$descending)
$sorts[]=$descending ? $attribute.$this->separators[1].$this->descTag : $attribute;
$params=$this->params===null ? $_GET : $this->params; | php | {
"resource": ""
} |
q19266 | CSort.resolveAttribute | train | public function resolveAttribute($attribute)
{
if($this->attributes!==array())
$attributes=$this->attributes;
elseif($this->modelClass!==null)
$attributes=$this->getModel($this->modelClass)->attributeNames();
else
return false;
foreach($attributes as $name=>$definition)
{
if(is_string($name))
... | php | {
"resource": ""
} |
q19267 | CSort.createLink | train | protected function createLink($attribute,$label,$url,$htmlOptions)
{
| php | {
"resource": ""
} |
q19268 | CCheckBoxColumn.init | train | public function init()
{
if(isset($this->checkBoxHtmlOptions['name']))
$name=$this->checkBoxHtmlOptions['name'];
else
{
$name=$this->id;
if(substr($name,-2)!=='[]')
$name.='[]';
$this->checkBoxHtmlOptions['name']=$name;
}
$name=strtr($name,array('['=>"\\[",']'=>"\\]"));
if($this->selectabl... | php | {
"resource": ""
} |
q19269 | CCheckBoxColumn.getDataCellContent | train | public function getDataCellContent($row)
{
$data=$this->grid->dataProvider->data[$row];
if($this->value!==null)
$value=$this->evaluateExpression($this->value,array('data'=>$data,'row'=>$row));
elseif($this->name!==null)
$value=CHtml::value($data,$this->name);
else
$value=$this->grid->dataProvider->key... | php | {
"resource": ""
} |
q19270 | CommentController.actionDelete | train | public function actionDelete()
{
if(Yii::app()->request->isPostRequest)
{
// we only allow deletion via POST request
$this->loadModel()->delete();
// if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
if(!isset($_POST['ajax']))
| php | {
"resource": ""
} |
q19271 | CommentController.actionApprove | train | public function actionApprove()
{
if(Yii::app()->request->isPostRequest)
{
$comment=$this->loadModel();
$comment->approve();
$this->redirect(array('index'));
}
else
throw | php | {
"resource": ""
} |
q19272 | CBaseUserIdentity.getState | train | public function getState($name,$defaultValue=null)
{
return | php | {
"resource": ""
} |
q19273 | CPagination.applyLimit | train | public function applyLimit($criteria)
{
$criteria->limit=$this->getLimit();
| php | {
"resource": ""
} |
q19274 | CGettextMessageSource.init | train | public function init()
{
parent::init();
if($this->basePath===null) | php | {
"resource": ""
} |
q19275 | CCaptchaValidator.getCaptchaAction | train | protected function getCaptchaAction()
{
if(($captcha=Yii::app()->getController()->createAction($this->captchaAction))===null)
{
if(strpos($this->captchaAction,'/')!==false) // contains controller or module
{
if(($ca=Yii::app()->createController($this->captchaAction))!==null)
{
list($controller,$... | php | {
"resource": ""
} |
q19276 | CFormatter.format | train | public function format($value,$type)
{
$method='format'.$type;
if(method_exists($this,$method))
return $this->$method($value);
else
| php | {
"resource": ""
} |
q19277 | CFormatter.normalizeDateValue | train | protected function normalizeDateValue($time)
{
if(is_string($time))
{
if(ctype_digit($time) || ($time{0}=='-' && ctype_digit(substr($time, 1))))
return (int)$time;
else
return strtotime($time);
| php | {
"resource": ""
} |
q19278 | CFormatter.formatUrl | train | public function formatUrl($value)
{
$url=$value;
if(strpos($url,'http://')!==0 && strpos($url,'https://')!==0)
| php | {
"resource": ""
} |
q19279 | CFormatter.formatSize | train | public function formatSize($value,$verbose=false)
{
$base=$this->sizeFormat['base'];
for($i=0; $base<=$value && $i<5; $i++)
$value=$value/$base;
$value=round($value, $this->sizeFormat['decimals']);
$formattedValue=isset($this->sizeFormat['decimalSeparator']) ? str_replace('.',$this->sizeFormat['decimalSepa... | php | {
"resource": ""
} |
q19280 | CConsoleCommand.run | train | public function run($args)
{
list($action, $options, $args)=$this->resolveRequest($args);
$methodName='action'.$action;
if(!preg_match('/^\w+$/',$action) || !method_exists($this,$methodName))
$this->usageError("Unknown action: ".$action);
$method=new ReflectionMethod($this,$methodName);
$params=array();
... | php | {
"resource": ""
} |
q19281 | CConsoleCommand.beforeAction | train | protected function beforeAction($action,$params)
{
if($this->hasEventHandler('onBeforeAction'))
{
$event = new CConsoleCommandEvent($this,$params,$action);
| php | {
"resource": ""
} |
q19282 | CConsoleCommand.afterAction | train | protected function afterAction($action,$params,$exitCode=0)
{
$event=new CConsoleCommandEvent($this,$params,$action,$exitCode);
| php | {
"resource": ""
} |
q19283 | CConsoleCommand.resolveRequest | train | protected function resolveRequest($args)
{
$options=array(); // named parameters
$params=array(); // unnamed parameters
foreach($args as $arg)
{
if(preg_match('/^--(\w+)(=(.*))?$/',$arg,$matches)) // an option
{
$name=$matches[1];
$value=isset($matches[3]) ? $matches[3] : true;
if(isset($opt... | php | {
"resource": ""
} |
q19284 | CConsoleCommand.getHelp | train | public function getHelp()
{
$help='Usage: '.$this->getCommandRunner()->getScriptName().' '.$this->getName();
$options=$this->getOptionHelp();
if(empty($options))
return $help."\n";
if(count($options)===1)
return $help.' '.$options[0]."\n";
| php | {
"resource": ""
} |
q19285 | CConsoleCommand.getOptionHelp | train | public function getOptionHelp()
{
$options=array();
$class=new ReflectionClass(get_class($this));
foreach($class->getMethods(ReflectionMethod::IS_PUBLIC) as $method)
{
$name=$method->getName();
if(!strncasecmp($name,'action',6) && strlen($name)>6)
{
$name=substr($name,6);
$name[0]=strtolower($... | php | {
"resource": ""
} |
q19286 | CConsoleCommand.copyFiles | train | public function copyFiles($fileList,$overwriteAll=false)
{
foreach($fileList as $name=>$file)
{
$source=strtr($file['source'],'/\\',DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR);
$target=strtr($file['target'],'/\\',DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR);
$callback=isset($file['callback']) ? $file['callback']... | php | {
"resource": ""
} |
q19287 | CConsoleCommand.ensureDirectory | train | public function ensureDirectory($directory)
{
if(!is_dir($directory))
{
$this->ensureDirectory(dirname($directory));
echo " | php | {
"resource": ""
} |
q19288 | CConsoleCommand.pluralize | train | public function pluralize($name)
{
$rules=array(
'/(m)ove$/i' => '\1oves',
'/(f)oot$/i' => '\1eet',
'/(c)hild$/i' => '\1hildren',
'/(h)uman$/i' => '\1umans',
'/(m)an$/i' => '\1en',
'/(s)taff$/i' => '\1taff',
'/(t)ooth$/i' => '\1eeth',
'/(p)erson$/i' => '\1eople',
'/([m|l])ouse$/i' => '\1ic... | php | {
"resource": ""
} |
q19289 | CPgsqlSchema.findPrimaryKey | train | protected function findPrimaryKey($table,$indices)
{
$indices=implode(', ',preg_split('/\s+/',$indices));
$sql=<<<EOD
SELECT attnum, attname FROM pg_catalog.pg_attribute WHERE
attrelid=(
SELECT oid FROM pg_catalog.pg_class WHERE relname=:table AND relnamespace=(
SELECT oid FROM pg_catalog.pg_namespace WHERE ... | php | {
"resource": ""
} |
q19290 | CPgsqlSchema.findForeignKey | train | protected function findForeignKey($table,$src)
{
$matches=array();
$brackets='\(([^\)]+)\)';
$pattern="/FOREIGN\s+KEY\s+{$brackets}\s+REFERENCES\s+([^\(]+){$brackets}/i";
if(preg_match($pattern,str_replace('"','',$src),$matches))
{
$keys=preg_split('/,\s+/', $matches[1]);
$tableName=$matches[2];
$fk... | php | {
"resource": ""
} |
q19291 | CMssqlCommandBuilder.createFindCommand | train | public function createFindCommand($table,$criteria,$alias='t')
{
$criteria=$this->checkCriteria($table,$criteria); | php | {
"resource": ""
} |
q19292 | CMssqlCommandBuilder.createUpdateCommand | train | public function createUpdateCommand($table,$data,$criteria)
{
$criteria=$this->checkCriteria($table,$criteria);
$fields=array();
$values=array();
$bindByPosition=isset($criteria->params[0]);
$i=0;
foreach($data as $name=>$value)
{
if(($column=$table->getColumn($name))!==null)
{
if ($table->sequ... | php | {
"resource": ""
} |
q19293 | CMssqlCommandBuilder.createDeleteCommand | train | public function createDeleteCommand($table,$criteria)
{
$criteria=$this->checkCriteria($table, $criteria);
return | php | {
"resource": ""
} |
q19294 | CMssqlCommandBuilder.applyJoin | train | public function applyJoin($sql,$join)
{
if(trim($join)!=='')
$sql=preg_replace('/^\s*DELETE\s+FROM\s+((\[.+\])|([^\s]+))\s*/i',"DELETE | php | {
"resource": ""
} |
q19295 | CMssqlCommandBuilder.applyLimit | train | public function applyLimit($sql, $limit, $offset)
{
$limit = $limit!==null ? (int)$limit : -1;
$offset = $offset!==null ? (int)$offset : -1;
if ($limit > 0 && $offset <= 0) //just limit
$sql | php | {
"resource": ""
} |
q19296 | CSysLogRoute.processLogs | train | protected function processLogs($logs)
{
static $syslogLevels=array(
CLogger::LEVEL_TRACE=>LOG_DEBUG,
CLogger::LEVEL_WARNING=>LOG_WARNING,
CLogger::LEVEL_ERROR=>LOG_ERR,
CLogger::LEVEL_INFO=>LOG_INFO,
CLogger::LEVEL_PROFILE=>LOG_DEBUG,
);
| php | {
"resource": ""
} |
q19297 | CActiveFinder.query | train | public function query($criteria,$all=false)
{
$this->joinAll=$criteria->together===true;
if($criteria->alias!='')
{
$this->_joinTree->tableAlias=$criteria->alias;
$this->_joinTree->rawTableAlias=$this->_builder->getSchema()->quoteTableName($criteria->alias);
}
$this->_joinTree->find($criteria);
$th... | php | {
"resource": ""
} |
q19298 | CJoinElement.destroy | train | public function destroy()
{
if(!empty($this->children))
{
foreach($this->children as $child)
$child->destroy(); | php | {
"resource": ""
} |
q19299 | CJoinElement.find | train | public function find($criteria=null)
{
if($this->_parent===null) // root element
{
$query=new CJoinQuery($this,$criteria);
$this->_finder->baseLimited=($criteria->offset>=0 || $criteria->limit>=0);
$this->buildQuery($query);
$this->_finder->baseLimited=false;
| php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.