_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q12000
Generator._ignoreKeyAlias
train
private static function _ignoreKeyAlias(array $t, Tag &$Tag) { extract($t); $single = self::getSingleAttrKey($Tag); if (isset(TagInfo::$ignoreAlisasesOnSingle[$single]) && in_array($alias, TagInfo::$ignoreAlisasesOnSingle[$single]) ) { return true; } return false; }
php
{ "resource": "" }
q12001
Generator.getSingleAttrKey
train
public static function getSingleAttrKey(Tag &$Tag) { if (isset(TagInfo::$singleAttrKeys[$Tag->name])) { return TagInfo::$singleAttrKeys[$Tag->name]; } else { return TagInfo::$defaultSingleAttrKey; } }
php
{ "resource": "" }
q12002
XmlStreamWriter.writeStartElement
train
public function writeStartElement(string $elementName): self { $this->doWriteStartElement($elementName); $this->depth++; return $this; }
php
{ "resource": "" }
q12003
XmlStreamWriter.writeEndElement
train
public function writeEndElement(): self { if ($this->isFinished()) { throw new \LogicException('Can not write end elements, no element open.'); } $this->doWriteEndElement(); $this->depth--; return $this; }
php
{ "resource": "" }
q12004
Cleaner.getClean
train
public static function getClean($str) { if (is_object($str) && get_class($str) == 'Xiphe\HTML\core\Tag') { $Tag = $str; $str = $Tag->content; } switch (Config::get('cleanMode')) { case 'strong': $str = self::getStrong($str); break; case 'basic': $str = self::getBasic($str); break; default: return $str; } if (isset($Tag)) { $Tag->content = $str; } return $str; }
php
{ "resource": "" }
q12005
Cleaner.getBasic
train
public static function getBasic($str) { $r = ''; /* * Split the string by line breakes. */ foreach (preg_split('/\n\r|\n|\r/', $str, -1, PREG_SPLIT_NO_EMPTY) as $k => $line) { /* * And append it with tabs and line breaks to the return var. */ $r .= Generator::getTabs(); $r .= trim($line); $r .= Generator::getLineBreak(); } return $r; }
php
{ "resource": "" }
q12006
Cleaner.parseAttrs
train
public static function parseAttrs($attr) { /* * Skip empty strings */ if (trim($attr) == '') { return ''; } /* * Match all attribute like parts from string. */ preg_match_all('/[a-zA-Z0-9-_:.]+(\s?=\s?("|\')[^\2]*\2|\s)/U', $attr, $attr); /* * Get the interessting part. */ $attr = $attr[0]; $r = array(); foreach ($attr as $k => $v) { /* * Skip empty matches */ if (trim($v) == '') { continue; } /* * Split by the first = symbol. */ $e = explode('=', $v, 2); /* * attribute name. */ $at = trim($e[0]); /* * attribute value. */ $val = isset($e[1]) ? trim($e[1]) : null; if ($val !== null) { /* * trim the quotation symbols */ $val = trim($val, substr($val, 0, 1)); } /* * store it in the return variable. */ $r[$at] = $val; } return $r; }
php
{ "resource": "" }
q12007
Cleaner.getStrong
train
public static function getStrong($str) { /* * Split the content by html tags. */ $tree = preg_split( '/(<[^!]?[^>]+>(<![^>]+>)?)/', $str, -1, PREG_SPLIT_OFFSET_CAPTURE | PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY ); /* * Initiate variables. */ $r = array(); $line = ''; $isInline = true; $oneLine = array(); $lastWasTag = false; /* * Loop throu the tree. */ foreach ($tree as $k => $elm) { /* * Check what kind of element this is. */ $info; switch (self::_getTreeElm($elm[0], $info)) { case 'start': /* * It's a starting tag */ $add = new Tag( $info[1], /* The Tags Name */ array(self::parseAttrs($info[2])), /* The attributes */ array( 'generate', ($info[3] == '/>' ? 'selfQlose' : 'doNotSelfQlose'), 'start', (in_array($info[1], TagInfo::$inlineTags) ? 'inline' : null) ) ); break; case 'end': /* * It is a closing tag */ $add = Store::get(); break; case 'comment': case 'content': default: /* * It's something else */ $add = $elm[0]; break; } /* * Add the current content to the output. */ self::_toLine($add, $r, $line, $isInline, $oneLine, $lastWasTag); } /* * Check if there is still content in the current line * and add it to the return array. */ if (strlen($line)) { $r[] = $line; } /* * implode the return array using line breaks and return the string. */ return implode(Generator::getLineBreak(), $r).Generator::getLineBreak(); }
php
{ "resource": "" }
q12008
Cleaner._getTreeElm
train
private static function _getTreeElm($str, &$info) { /* * Normalize the string. */ $str = preg_replace('/(\n\r|\n|\r|\s)+/', ' ', $str); /* * Identify it by checking its first symbols. */ if (strpos($str, '</') === 0) { return 'end'; } elseif (strpos($str, '<!') === 0) { return 'content'; } elseif (strpos($str, '<!--') === 0) { return 'comment'; } elseif (strpos($str, '<') === 0) { preg_match('/<([a-zA-Z0-9]+)(.*?(?=\/>|>))(\/>|>)+/', $str, $info); return 'start'; } return 'content'; }
php
{ "resource": "" }
q12009
XslProcessorProvider.callbacks
train
protected function callbacks(): array { if (!is_array($this->callbackList)) { if (!file_exists($this->configPath . '/xsl-callbacks.ini')) { $this->callbackList = []; } else { $this->callbackList = @parse_ini_file($this->configPath . '/xsl-callbacks.ini'); if (false === $this->callbackList) { throw new XslCallbackException( 'XSL callback in ' . $this->configPath . '/xsl-callbacks.ini contains errors and can not be parsed.' ); } } } return $this->callbackList; }
php
{ "resource": "" }
q12010
BasicModule.init
train
final public function init(&$args, &$options, &$called) { $this->args = &$args; $this->options = &$options; $this->called = &$called; /* * Execute Module generated Hook if Wordpress is available. */ if (class_exists('\WP')) { call_user_func_array('do_action', array('Xiphe\HTML\ModuleCreated', &$this, Config::getHTMLInstance())); } }
php
{ "resource": "" }
q12011
BasicModule.generate
train
final public function generate() { $options = array_merge($this->options, (array) 'generate'); Generator::call($this->called, $this->args, $options); }
php
{ "resource": "" }
q12012
WSClientDataCollector.onWSClientCommand
train
public function onWSClientCommand(WSEventDispatcher\WSClientEvent $event) { //$command = $event->getCommand(); //$arguments = $event->getArguments(); $this->data['commands'][] = array( 'command' => $event->getCommand(), 'arguments' => $event->getArguments(), 'url' => $event->getUrl(), 'cache' => $event->getUseCache(), 'content' => $event->getContent(), 'key' => $event->getKey(), 'statusCode' => $event->getStatusCode(), 'executiontime' => $event->getTiming() ); }
php
{ "resource": "" }
q12013
XmlSerializer.serialize
train
public function serialize( $value, XmlStreamWriter $xmlWriter, string $tagName = null, string $elementTagName = null ): XmlStreamWriter { switch (gettype($value)) { case 'NULL': $this->serializeNull($xmlWriter, $tagName); break; case 'boolean': $this->serializeBool($value, $xmlWriter, $tagName); break; case 'string': case 'integer': case 'double': $this->serializeScalarValue($value, $xmlWriter, $tagName); break; case 'array': $this->serializeArray($value, $xmlWriter, $tagName, $elementTagName); break; case 'object': if ($value instanceof \Traversable && !annotationsOf($value)->contain('XmlNonTraversable')) { if (null === $tagName && $value instanceof \Traversable && annotationsOf($value)->contain('XmlTag')) { $annotation = annotationsOf($value)->firstNamed('XmlTag'); $tagName = $annotation->getTagName(); $elementTagName = $annotation->getElementTagName(); } $this->serializeArray($value, $xmlWriter, $tagName, $elementTagName); } else { $this->serializeObject($value, $xmlWriter, $tagName); } break; default: // nothing to do } return $xmlWriter; }
php
{ "resource": "" }
q12014
XmlSerializer.serializeNull
train
public function serializeNull(XmlStreamWriter $xmlWriter, string $tagName = null): XmlStreamWriter { return $xmlWriter->writeStartElement(null === $tagName ? 'null' : $tagName) ->writeElement('null') ->writeEndElement(); }
php
{ "resource": "" }
q12015
XmlSerializer.serializeBool
train
public function serializeBool($value, XmlStreamWriter $xmlWriter, string $tagName = null): XmlStreamWriter { return $this->serializeScalarValue( $this->convertBoolToString($value), $xmlWriter, null === $tagName ? 'boolean' : $tagName ); }
php
{ "resource": "" }
q12016
XmlSerializer.serializeFloat
train
public function serializeFloat($value, XmlStreamWriter $xmlWriter, string $tagName = null): XmlStreamWriter { return $this->serializeScalarValue($value, $xmlWriter, $tagName); }
php
{ "resource": "" }
q12017
XmlSerializer.serializeScalarValue
train
protected function serializeScalarValue($value, XmlStreamWriter $xmlWriter, string $tagName = null): XmlStreamWriter { return $xmlWriter->writeStartElement(null === $tagName ? gettype($value) : $tagName) ->writeText(strval($value)) ->writeEndElement(); }
php
{ "resource": "" }
q12018
XmlSerializer.serializeArray
train
public function serializeArray( $array, XmlStreamWriter $xmlWriter, string $tagName = null, string $elementTagName = null ): XmlStreamWriter { if (null === $tagName) { $tagName = 'array'; } if (!empty($tagName)) { $xmlWriter->writeStartElement($tagName); } foreach ($array as $key => $value) { if (is_int($key)) { $this->serialize($value, $xmlWriter, $elementTagName); } else { $this->serialize($value, $xmlWriter, $key); } } if (!empty($tagName)) { $xmlWriter->writeEndElement(); } return $xmlWriter; }
php
{ "resource": "" }
q12019
XmlSerializer.serializeObject
train
public function serializeObject($object, XmlStreamWriter $xmlWriter, string $tagName = null): XmlStreamWriter { $this->serializerFor($object)->serialize($object, $this, $xmlWriter, $tagName); return $xmlWriter; }
php
{ "resource": "" }
q12020
XmlSerializer.serializerFor
train
protected function serializerFor($object): ObjectXmlSerializer { if (!annotationsOf($object)->contain('XmlSerializer')) { return AnnotationBasedObjectXmlSerializer::fromObject($object); } return $this->injector->getInstance( annotationsOf($object) ->firstNamed('XmlSerializer') ->getValue() ->getName() ); }
php
{ "resource": "" }
q12021
XslProcessor.onXmlFile
train
public function onXmlFile(string $xmlFile, bool $xinclude = true): self { $doc = new \DOMDocument(); if (false === @$doc->load($xmlFile)) { throw new XslProcessorException( 'Can not read xml document file ' . $xmlFile ); } if (true === $xinclude) { $doc->xinclude(); } return $this->onDocument($doc); }
php
{ "resource": "" }
q12022
XslProcessor.applyStylesheet
train
public function applyStylesheet(\DOMDocument $stylesheet): self { $this->stylesheets[] = $stylesheet; $this->xsltProcessor->importStylesheet($stylesheet); return $this; }
php
{ "resource": "" }
q12023
XslProcessor.applyStylesheetFromFile
train
public function applyStylesheetFromFile(string $stylesheetFile): self { $stylesheet = new \DOMDocument(); if (false === @$stylesheet->load($stylesheetFile)) { throw new XslProcessorException('Can not read stylesheet file ' . $stylesheetFile); } return $this->applyStylesheet($stylesheet); }
php
{ "resource": "" }
q12024
XslProcessor.usingCallback
train
public function usingCallback(string $name, $instance): self { $this->xslCallbacks->addCallback($name, $instance); return $this; }
php
{ "resource": "" }
q12025
XslProcessor.registerCallbacks
train
protected function registerCallbacks() { self::$_callbacks = $this->xslCallbacks; $this->xsltProcessor->registerPHPFunctions(get_class($this) . '::invokeCallback'); }
php
{ "resource": "" }
q12026
XslProcessor.withParameter
train
public function withParameter(string $nameSpace, string $paramName, string $paramValue): self { if (false === $this->xsltProcessor->setParameter($nameSpace, $paramName, $paramValue)) { throw new XslProcessorException( 'Could not set parameter ' . $nameSpace . ':' . $paramName . ' with value ' . $paramValue ); } if (!isset($this->parameters[$nameSpace])) { $this->parameters[$nameSpace] = []; } $this->parameters[$nameSpace][$paramName] = $paramValue; return $this; }
php
{ "resource": "" }
q12027
XslProcessor.withParameters
train
public function withParameters(string $nameSpace, array $params): self { if (false === $this->xsltProcessor->setParameter($nameSpace, $params)) { throw new XslProcessorException('Could not set parameters in ' . $nameSpace); } if (!isset($this->parameters[$nameSpace])) { $this->parameters[$nameSpace] = []; } $this->parameters[$nameSpace] = array_merge($this->parameters[$nameSpace], $params); return $this; }
php
{ "resource": "" }
q12028
XslProcessor.toDoc
train
public function toDoc(): \DOMDocument { if (null === $this->document) { throw new XslProcessorException( 'Can not transform, set document or xml file to transform first' ); } $this->registerCallbacks(); $result = $this->xsltProcessor->transformToDoc($this->document); if (false === $result) { throw new XslProcessorException($this->createMessage()); } return $result; }
php
{ "resource": "" }
q12029
XslProcessor.toUri
train
public function toUri(string $uri): int { if (null === $this->document) { throw new XslProcessorException( 'Can not transform, set document or xml file to transform first' ); } $this->registerCallbacks(); $bytes = $this->xsltProcessor->transformToURI($this->document, $uri); if (false === $bytes) { throw new XslProcessorException($this->createMessage()); } return $bytes; }
php
{ "resource": "" }
q12030
XslProcessor.toXml
train
public function toXml(): string { if (null === $this->document) { throw new XslProcessorException( 'Can not transform, set document or xml file to transform first' ); } $this->registerCallbacks(); $result = $this->xsltProcessor->transformToXML($this->document); if (false === $result) { throw new XslProcessorException($this->createMessage()); } return $result; }
php
{ "resource": "" }
q12031
XslProcessor.createMessage
train
private function createMessage(): string { $message = ''; foreach (libxml_get_errors() as $error) { $message .= trim($error->message) . (($error->file) ? (' in file ' . $error->file) : ('')) . ' on line ' . $error->line . ' in column ' . $error->column . "\n"; } libxml_clear_errors(); if (strlen($message) === 0) { return 'Transformation failed: unknown error.'; } return $message; }
php
{ "resource": "" }
q12032
XmlStreamWriterProvider.createStreamWriter
train
protected function createStreamWriter(string $xmlExtension): XmlStreamWriter { $className = $this->types[$xmlExtension]; return new $className($this->version, $this->encoding); }
php
{ "resource": "" }
q12033
XmlStreamWriterProvider.createAsAvailable
train
protected function createAsAvailable(): XmlStreamWriter { foreach (array_keys($this->types) as $xmlExtension) { if (extension_loaded($xmlExtension)) { return $this->createStreamWriter($xmlExtension); } } throw new XmlException( 'No supported xml extension available, can not create a xml stream writer!' ); }
php
{ "resource": "" }
q12034
Db.asManyToMany
train
public function asManyToMany($alias, $junction, $column, $table, $pk, $columns = '*') { $this->relationProcessor->queue(__FUNCTION__, func_get_args()); return $this; }
php
{ "resource": "" }
q12035
Db.asOneToOne
train
public function asOneToOne($column, $alias, $table, $link) { $this->relationProcessor->queue(__FUNCTION__, func_get_args()); return $this; }
php
{ "resource": "" }
q12036
Db.asOneToMany
train
public function asOneToMany($table, $pk, $alias) { $this->relationProcessor->queue(__FUNCTION__, func_get_args()); return $this; }
php
{ "resource": "" }
q12037
Db.asData
train
private function asData(array $data) { foreach ($data as $key => $value) { if ($value instanceof RawSqlFragmentInterface) { $data[$key] = $value->getFragment(); } elseif ($value instanceof RawBindingInterface) { $data[$key] = $value->getTarget(); } else { $placeholder = $this->getUniqPlaceholder(); $data[$key] = $placeholder; $this->bind($placeholder, $value); } } return $data; }
php
{ "resource": "" }
q12038
Db.createUniqPlaceholder
train
private function createUniqPlaceholder($key) { if ($key instanceof RawSqlFragment) { $placeholder = $key->getFragment(); } else if ($key instanceof RawBindingInterface) { $placeholder = $key->getTarget(); } else { // Create unique placeholder $placeholder = $this->getUniqPlaceholder(); // Bind to the global stack $this->bind($placeholder, $key); } return $placeholder; }
php
{ "resource": "" }
q12039
Db.getCount
train
private function getCount($column) { $alias = 'count'; // Save initial state $original = clone $this->queryBuilder; $bindings = $this->bindings; // Set guessed query and execute it $this->queryBuilder->setQueryString($this->queryBuilder->guessCountQuery($column, $alias)); $count = $this->query($alias); // And finally restore initial state $this->queryBuilder = $original; $this->bindings = $bindings; return $count; }
php
{ "resource": "" }
q12040
Db.fetchAllTables
train
public function fetchAllTables() { $tables = array(); $result = $this->pdo->query('SHOW TABLES')->fetchAll(); foreach ($result as $index => $array) { // Extract a value - we don't care about a key $data = array_values($array); // Its ready not, just append it $tables[] = $data[0]; } return $tables; }
php
{ "resource": "" }
q12041
Db.dump
train
public function dump(array $tables = array()) { $result = null; if (empty($tables)) { $tables = $this->fetchAllTables(); } // Building logic foreach ($tables as $table) { // Main SELECT query $select = $this->queryBuilder->clear() ->select('*') ->from($table) ->getQueryString(); $stmt = $this->pdo->query($select); $fieldCount = $stmt->columnCount(); // Append additional drop state $result .= $this->queryBuilder->clear() ->dropTable($table) ->getQueryString();; // Show how this table was created $createResult = $this->pdo->query(sprintf('SHOW CREATE TABLE %s', $table))->fetch(); $result .= "\n\n" . $createResult['Create Table'] . ";\n\n"; // Start main loop for ($i = 0; $i < $fieldCount; $i++) { // Loop to generate INSERT statements while ($row = $stmt->fetch(PDO::FETCH_NUM)) { $values = array(); // Extra values and push them to $values array for ($j = 0; $j < $fieldCount; $j++) { // We need to ensure all quotes are properly escaped $row[$j] = addslashes($row[$j]); // Ensure its correctly escaped $row[$j] = str_replace("\n", "\\n", $row[$j]); $row[$j] = sprintf('"%s"', $row[$j]); // Push the value array_push($values, $row[$j]); } // Generate short INSERT statement $result .= $this->queryBuilder->clear() ->insertShort($table, $values) ->getQueryString(); $result .= "\n"; // Free memory for next iteration unset($vals); } } $result .= "\n"; } return $result; }
php
{ "resource": "" }
q12042
Db.paginateRaw
train
public function paginateRaw($count, $page, $itemsPerPage) { $this->paginator->tweak($count, $itemsPerPage, $page); $this->limit($this->paginator->countOffset(), $this->paginator->getItemsPerPage()); return $this; }
php
{ "resource": "" }
q12043
Db.paginate
train
public function paginate($page, $itemsPerPage, $column = '1') { $count = $this->getCount($column); if ($this->isDriver('mysql') || $this->isDriver('sqlite')) { // Alter paginator's state $this->paginateRaw($count, $page, $itemsPerPage); } else { throw new RuntimeException('Smart pagination algorithm is currently supported only for MySQL and SQLite'); } return $this; }
php
{ "resource": "" }
q12044
Db.getPrimaryKey
train
public function getPrimaryKey($table) { $db = $this->showKeys()->from($table) ->whereEquals('Key_name', new RawBinding('PRIMARY')); return $db->query('Column_name'); }
php
{ "resource": "" }
q12045
Db.raw
train
public function raw($query, array $bindings = array()) { if (!empty($bindings)) { foreach ($bindings as $column => $value) { $this->bind($column, $value); } } $this->queryBuilder->raw($query); return $this; }
php
{ "resource": "" }
q12046
Db.getStmt
train
public function getStmt() { // Make sure there are no nested arrays if (ArrayUtils::hasAtLeastOneArrayValue($this->bindings)) { throw new RuntimeException('PDO bindings can not contain nested arrays'); } // Build target query before bindings are cleared purely for logging purpose $log = str_replace(array_keys($this->bindings), array_values($this->bindings), $this->queryBuilder->getQueryString()); // Execute it $stmt = $this->pdo->prepare($this->queryBuilder->getQueryString()); $stmt->execute($this->bindings); // Log target query $this->queryLogger->add($log); // Clear the buffer $this->clear(); return $stmt; }
php
{ "resource": "" }
q12047
Db.queryAll
train
public function queryAll($column = null, $mode = null) { if (is_null($mode)) { $mode = $this->pdo->getAttribute(PDO::ATTR_DEFAULT_FETCH_MODE); } $result = array(); $rows = $this->getStmt()->fetchAll($mode); if ($column == null) { $result = $rows; } else { foreach ($rows as $row) { if (isset($row[$column])) { $result[] = $row[$column]; } else { return false; } } } if ($this->relationProcessor->hasQueue()) { return $this->relationProcessor->process($result); } else { return $result; } }
php
{ "resource": "" }
q12048
Db.query
train
public function query($column = null, $mode = null) { if (is_null($mode)) { $mode = $this->pdo->getAttribute(PDO::ATTR_DEFAULT_FETCH_MODE); } $result = array(); $rows = $this->getStmt()->fetch($mode); if ($column !== null) { if (isset($rows[$column])) { $result = $rows[$column]; } else { $result = false; } } else { $result = $rows; } if ($this->relationProcessor->hasQueue()) { $data = $this->relationProcessor->process(array($result)); return isset($data[0]) ? $data[0] : false; } // By default return $result; }
php
{ "resource": "" }
q12049
Db.queryScalar
train
public function queryScalar($mode = null) { $result = $this->query(null, $mode); if (is_array($result)) { // Filter by values $result = array_values($result); return isset($result[0]) ? $result[0] : false; } return false; }
php
{ "resource": "" }
q12050
Db.increment
train
public function increment($table, $column, $step = 1) { $this->queryBuilder->increment($table, $column, $step); return $this; }
php
{ "resource": "" }
q12051
Db.decrement
train
public function decrement($table, $column, $step = 1) { $this->queryBuilder->decrement($table, $column, $step); return $this; }
php
{ "resource": "" }
q12052
Db.equals
train
public function equals($column, $value, $filter = false) { return $this->compare($column, '=', $value, $filter); }
php
{ "resource": "" }
q12053
Db.notEquals
train
public function notEquals($column, $value, $filter = false) { return $this->compare($column, '!=', $value, $filter); }
php
{ "resource": "" }
q12054
Db.like
train
public function like($column, $value, $filter = false) { return $this->compare($column, 'LIKE', $value, $filter); }
php
{ "resource": "" }
q12055
Db.notLike
train
public function notLike($column, $value, $filter = false) { return $this->compare($column, 'NOT LIKE', $value, $filter); }
php
{ "resource": "" }
q12056
Db.greaterThan
train
public function greaterThan($column, $value, $filter = false) { return $this->compare($column, '>', $value, $filter); }
php
{ "resource": "" }
q12057
Db.lessThan
train
public function lessThan($column, $value, $filter = false) { return $this->compare($column, '<', $value, $filter); }
php
{ "resource": "" }
q12058
Db.orWhereBetween
train
public function orWhereBetween($column, $a, $b, $filter = false) { return $this->between(__FUNCTION__, $column, $a, $b, $filter); }
php
{ "resource": "" }
q12059
Db.between
train
private function between($method, $column, $a, $b, $filter) { if (!$this->queryBuilder->isFilterable($filter, array($a, $b))) { return $this; } if ($a instanceof RawSqlFragmentInterface) { $x = $a->getFragment(); } if ($b instanceof RawSqlFragmentInterface) { $y = $b->getFragment(); } // When doing betweens, unique placeholders come in handy if (!isset($x)) { $x = $this->getUniqPlaceholder(); } if (!isset($y)) { $y = $this->getUniqPlaceholder(); } // Prepare query string call_user_func(array($this->queryBuilder, $method), $column, $x, $y, $filter); // And finally bind values if (!($a instanceof RawSqlFragmentInterface)) { $this->bind($x, $a); } if (!($b instanceof RawSqlFragmentInterface)) { $this->bind($y, $b); } return $this; }
php
{ "resource": "" }
q12060
Db.constraint
train
private function constraint($method, $column, $operator, $value, $filter) { if (!$this->queryBuilder->isFilterable($filter, $value)) { return $this; } call_user_func(array($this->queryBuilder, $method), $column, $operator, $this->createUniqPlaceholder($value)); return $this; }
php
{ "resource": "" }
q12061
Db.whereInValues
train
private function whereInValues($method, $column, $values, $filter) { if (!$this->queryBuilder->isFilterable($filter, $values)) { return $this; } if ($values instanceof RawBindingInterface) { call_user_func(array($this->queryBuilder, $method), $column, $values->getTarget(), $filter); } elseif ($values instanceof RawSqlFragmentInterface) { call_user_func(array($this->queryBuilder, $method), $column, $values, $filter); } else { // Prepare bindings, firstly $bindings = array(); foreach ($values as $value) { // Generate unique placeholder $placeholder = $this->getUniqPlaceholder(); // Append to collection $bindings[$placeholder] = $value; } call_user_func(array($this->queryBuilder, $method), $column, array_keys($bindings), $filter); // Now bind what we have so far foreach ($bindings as $key => $value) { $this->bind($key, $value); } } return $this; }
php
{ "resource": "" }
q12062
Db.where
train
public function where($column, $operator, $value, $filter = false) { return $this->constraint(__FUNCTION__, $column, $operator, $value, $filter); }
php
{ "resource": "" }
q12063
Db.orWhereEquals
train
public function orWhereEquals($column, $value, $filter = false) { return $this->orWhere($column, '=', $value, $filter); }
php
{ "resource": "" }
q12064
Db.orWhereNotEquals
train
public function orWhereNotEquals($column, $value, $filter = false) { return $this->orWhere($column, '!=', $value, $filter); }
php
{ "resource": "" }
q12065
Db.orWhereGreaterThanOrEquals
train
public function orWhereGreaterThanOrEquals($column, $value, $filter = false) { return $this->orWhere($column, '>=', $value, $filter); }
php
{ "resource": "" }
q12066
Db.orWhereLessThanOrEquals
train
public function orWhereLessThanOrEquals($column, $value, $filter = false) { return $this->orWhere($column, '<=', $value, $filter); }
php
{ "resource": "" }
q12067
Db.whereGreaterThan
train
public function whereGreaterThan($column, $value, $filter = false) { return $this->where($column, '>', $value, $filter); }
php
{ "resource": "" }
q12068
Db.andWhereGreaterThan
train
public function andWhereGreaterThan($column, $value, $filter = false) { return $this->andWhere($column, '>', $value, $filter); }
php
{ "resource": "" }
q12069
Db.andWhereLessThan
train
public function andWhereLessThan($column, $value, $filter = false) { return $this->andWhere($column, '<', $value, $filter); }
php
{ "resource": "" }
q12070
Db.whereLessThan
train
public function whereLessThan($column, $value, $filter = false) { return $this->where($column, '<', $value, $filter); }
php
{ "resource": "" }
q12071
Db.orWhereLessThan
train
public function orWhereLessThan($column, $value, $filter = false) { return $this->orWhere($column, '<', $value, $filter); }
php
{ "resource": "" }
q12072
Db.orWhereGreaterThan
train
public function orWhereGreaterThan($column, $value, $filter = false) { return $this->orWhere($column, '>', $value, $filter); }
php
{ "resource": "" }
q12073
Db.andWhereLike
train
public function andWhereLike($column, $value, $filter = false) { return $this->andWhere($column, 'LIKE', $value, $filter); }
php
{ "resource": "" }
q12074
Db.andWhereNotLike
train
public function andWhereNotLike($column, $value, $filter = false) { return $this->andWhere($column, 'NOT LIKE', $value, $filter); }
php
{ "resource": "" }
q12075
Db.orWhereLike
train
public function orWhereLike($column, $value, $filter = false) { return $this->orWhere($column, 'LIKE', $value, $filter); }
php
{ "resource": "" }
q12076
Db.orWhereNotLike
train
public function orWhereNotLike($column, $value, $filter = false) { return $this->orWhere($column, 'NOT LIKE', $value, $filter); }
php
{ "resource": "" }
q12077
Db.whereLike
train
public function whereLike($column, $value, $filter = false) { return $this->where($column, 'LIKE', $value, $filter); }
php
{ "resource": "" }
q12078
Db.andWhereEquals
train
public function andWhereEquals($column, $value, $filter = false) { return $this->andWhere($column, '=', $value, $filter); }
php
{ "resource": "" }
q12079
Db.andWhereNotEquals
train
public function andWhereNotEquals($column, $value, $filter = false) { return $this->andWhere($column, '!=', $value, $filter); }
php
{ "resource": "" }
q12080
Db.andWhereEqualsOrGreaterThan
train
public function andWhereEqualsOrGreaterThan($column, $value, $filter = false) { return $this->andWhere($column, '>=', $value, $filter); }
php
{ "resource": "" }
q12081
Db.andWhereEqualsOrLessThan
train
public function andWhereEqualsOrLessThan($column, $value, $filter = false) { return $this->andWhere($column, '<=', $value, $filter); }
php
{ "resource": "" }
q12082
Db.dropTable
train
public function dropTable($table, $ifExists = true) { $this->queryBuilder->dropTable($table, $ifExists); return $this; }
php
{ "resource": "" }
q12083
CommentForm.CommentStore
train
public function CommentStore($data, $form) { /** * If the "Extra" field is filled, we have a bot. * Also, the nsas (<noscript> Anti Spam) is a bot. Bot's don't use javascript. * Note, a legitimate visitor that has JS disabled, will be unable to post! */ if (!isset($data['Extra']) || $data['Extra'] == '' || isset($data['nsas'])) { $data['Comment'] = Convert::raw2sql($data['Comment']); $exists = Comment::get() ->filter(array('Comment:PartialMatch' => $data['Comment'])) ->where('ABS(TIMEDIFF(NOW(), Created)) < 60'); if (!$exists->count()) { $comment = Comment::create(); $form->saveInto($comment); $comment->NewsID = $data['NewsID']; $comment->write(); } } Controller::curr()->redirectBack(); }
php
{ "resource": "" }
q12084
Exceptions.flattenArgument
train
private static function flattenArgument (&$value, $key) { if ($value instanceof Closure) { $closureReflection = new ReflectionFunction($value); $value = sprintf('(Closure at %s:%s)', $closureReflection->getFileName(), $closureReflection->getStartLine()); } elseif (is_object($value)) { $value = sprintf('object(%s)', get_class($value)); } elseif (is_resource($value)) { $value = sprintf('resource(%s)', get_resource_type($value)); } }
php
{ "resource": "" }
q12085
Element.dynamic
train
public static function dynamic($type, $name, $value, array $attributes = array(), $extra = array()) { switch ($type) { case 'text': return self::text($name, $value, $attributes); case 'password': return self::password($name, $value, $attributes); case 'url': return self::url($name, $value, $attributes); case 'range': return self::range($name, $value, $attributes); case 'number': return self::number($name, $value, $attributes); case 'hidden': return self::hidden($name, $value, $attributes); case 'date': return self::date($name, $value, $attributes); case 'time': return self::time($name, $value, $attributes); case 'color': return self::color($name, $value, $attributes); case 'textarea': return self::textarea($name, $value, $attributes); case 'radio': return self::radio($name, $value, (bool) $value, $attributes); case 'checkbox': return self::checkbox($name, $value, $attributes, false); case 'select': return self::select($name, $extra, $value, $attributes); default: throw new UnexpectedValueException(sprintf('Unexpected value supplied %s', $type)); } }
php
{ "resource": "" }
q12086
Element.icon
train
public static function icon($icon, $link, array $attributes = array()) { // Inner text $text = sprintf('<i class="%s"></i> ', $icon); return self::link($text, $link, $attributes); }
php
{ "resource": "" }
q12087
Element.link
train
public static function link($text, $link = '#', array $attributes = array()) { if (!is_null($link)) { $attributes['href'] = $link; } $node = new Node\Link($text); return $node->render($attributes); }
php
{ "resource": "" }
q12088
Element.option
train
public static function option($value, $text, array $attributes = array()) { if (!is_null($value)) { $attributes['value'] = $value; } $node = new Node\Option($text); return $node->render($attributes); }
php
{ "resource": "" }
q12089
Element.button
train
public static function button($text, array $attributes = array()) { $node = new Node\Button($text); return $node->render($attributes); }
php
{ "resource": "" }
q12090
Element.radio
train
public static function radio($name, $value, $checked, array $attributes = array()) { if (!is_null($name)) { $attributes['name'] = $name; } if (!is_null($value)) { $attributes['value'] = $value; } $node = new Node\Radio($checked); return $node->render($attributes); }
php
{ "resource": "" }
q12091
Element.checkbox
train
public static function checkbox($name, $checked, array $attributes = array(), $serialize = true) { if ($name !== null) { $attributes['name'] = $name; } $node = new Node\Checkbox($serialize, $checked); return $node->render($attributes); }
php
{ "resource": "" }
q12092
Element.file
train
public static function file($name, $accept = null, array $attributes = array()) { if (!is_null($name)) { $attributes['name'] = $name; } if (!is_null($accept)) { $attributes['accept'] = $accept; } $node = new Node\File(); return $node->render($attributes); }
php
{ "resource": "" }
q12093
Element.select
train
public static function select($name, array $list = array(), $selected, array $attributes = array(), $prompt = false, Closure $optionVisitor = null) { if ($prompt !== false) { // Merge keeping indexes $list = array('' => $prompt) + $list; } $node = new Node\Select($list, $selected, array(), $optionVisitor); if ($name !== null) { $attributes['name'] = $name; } return $node->render($attributes); }
php
{ "resource": "" }
q12094
Element.textarea
train
public static function textarea($name, $text, array $attributes = array()) { if ($name !== null) { $attributes['name'] = $name; } $node = new Node\Textarea($text); return $node->render($attributes); }
php
{ "resource": "" }
q12095
Element.text
train
public static function text($name, $value, array $attributes = array()) { $node = new Node\Text(); if (!is_null($name)) { $attributes['name'] = $name; } if (!is_null($value)) { $attributes['value'] = $value; } return $node->render($attributes); }
php
{ "resource": "" }
q12096
Element.color
train
public static function color($name, $value, array $attributes = array()) { $node = new Node\Color(); if (!is_null($name)) { $attributes['name'] = $name; } if (!is_null($value)) { $attributes['value'] = $value; } return $node->render($attributes); }
php
{ "resource": "" }
q12097
Element.email
train
public static function email($name, $value, array $attributes = array()) { $node = new Node\Email(); if (!is_null($name)) { $attributes['name'] = $name; } if (!is_null($value)) { $attributes['value'] = $value; } return $node->render($attributes); }
php
{ "resource": "" }
q12098
Element.hidden
train
public static function hidden($name, $value, array $attributes = array()) { $node = new Node\Hidden(); if (!is_null($name)) { $attributes['name'] = $name; } if (!is_null($value)) { $attributes['value'] = $value; } return $node->render($attributes); }
php
{ "resource": "" }
q12099
Element.number
train
public static function number($name, $value, array $attributes = array()) { $node = new Node\Number(); if (!is_null($name)) { $attributes['name'] = $name; } if (!is_null($value)) { $attributes['value'] = $value; } return $node->render($attributes); }
php
{ "resource": "" }