_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q235800
JsonApiResponse.getRelationships
train
private function getRelationships(Item $item) { if ($include_params = $this->resource->getIncludeParams()) { $item->setIncludeParams($include_params); return $item->getIncluded(); } return []; }
php
{ "resource": "" }
q235801
JsonApiResponse.setMeta
train
public function setMeta() { if ($meta = $this->resource->getMeta()) { $this->meta = $meta; } else { unset($this->meta); } return $this; }
php
{ "resource": "" }
q235802
Table.setLinkFieldKey
train
public function setLinkFieldKey($linkFieldKey) { if (!is_string($linkFieldKey)) { $msg = "Link field key must be a string"; throw new OpenStates_View_Exception($msg); } $this->linkFieldKey = $linkFieldKey; return $this; }
php
{ "resource": "" }
q235803
Table.setLabelPrefix
train
public function setLabelPrefix($labelPrefix) { if (!is_string($labelPrefix)) { $msg = "Label prefix must be a string"; throw new OpenStates_View_Exception($msg); } $this->labelPrefix = $labelPrefix; return $this; }
php
{ "resource": "" }
q235804
Config.loadFile
train
private function loadFile(string $path) { if (!file_exists($path)) { throw new Exception('Configuration file "' . $path . '" is not found'); } if (!is_readable($path)) { throw new Exception('Configuration file "' . $path . '" is not readable'); } // ...
php
{ "resource": "" }
q235805
Config.load
train
public function load(string $path, string $key = null): ConfigInterface { try { // Read parameters from file $parameters = $this->loadFile($path); // If key is provided then need put parameters into subarray if (null !== $key) { $parameters = ...
php
{ "resource": "" }
q235806
Config.setter
train
private function setter(array $parameters) { // Parse array and set values array_map( function($key, $value) { $this->set($key, $value); }, array_keys($parameters), $parameters ); }
php
{ "resource": "" }
q235807
Config.set
train
public function set(string $key, $value): ConfigInterface { $this->_config[$key] = \is_array($value) ? new Config($value) : $value; return $this; }
php
{ "resource": "" }
q235808
Config.get
train
public function get(string $key = null) { $result = (null !== $key) ? $this->_config[$key] ?? null : $this->_config; return $result; }
php
{ "resource": "" }
q235809
Config.clean
train
public function clean(string $key = null): ConfigInterface { if (null !== $key) { unset($this->_config[$key]); } else { $this->_config = []; } return $this; }
php
{ "resource": "" }
q235810
Repository.loadKey
train
protected function loadKey($key) { // Pegar soh o primeiro key $parts = explode('.', $key); $first = $parts[0]; // Verificar se item já foi adicionado if (array_key_exists($first, $this->items)) { return; } if (array_key_exists($first, $this->fin...
php
{ "resource": "" }
q235811
JournalContactImporter.importContacts
train
public function importContacts($journal, $journalId) { $this->consoleOutput->writeln("Importing journal's contacts..."); $settingsSql = "SELECT locale, setting_name, setting_value FROM journal_settings WHERE journal_id = :id"; $settingsStatement = $this->dbalConnection->prepare($settingsSql...
php
{ "resource": "" }
q235812
UrlAsset.setViewParams
train
public function setViewParams($view) { foreach ($this->url as $url) { if(isset($view->params['urls']) && is_array($view->params['urls'])){ $view->params['urls'] = $this->MenuMerge($view->params['urls'],$url); }else{ $view->params['urls'] = $ur...
php
{ "resource": "" }
q235813
ORM.getObjectChangeSet
train
public function getObjectChangeSet($uow, $object) { $changeSet = parent::getObjectChangeSet($uow, $object); $meta = $this->getObjectManager()->getClassMetadata(get_class($object)); $refl = $meta->getReflectionClass(); $updates = $uow->getScheduledCollectionUpdates(); $delitio...
php
{ "resource": "" }
q235814
Assets.css
train
public static function css($files, $nest = true) { if (is_array($files)) { foreach ($files as $file) { self::cssCall($file, $nest); } } elseif (is_string($files)) { self::cssCall($files, $nest); } }
php
{ "resource": "" }
q235815
Assets.cssCall
train
public static function cssCall($file, $nest) { if (strpos($file, 'http://') !== false) { $path = $file.'.css'; } else { if ($nest) { $file = str_replace('.', '/', $file); $path = path().'assets/css/'.$file.'.css'; } else { ...
php
{ "resource": "" }
q235816
Assets.js
train
public static function js($files, $nest = true) { if (is_array($files)) { foreach ($files as $file) { self::jsCall($file, $nest); } } elseif (is_string($files)) { self::jsCall($files, $nest); } }
php
{ "resource": "" }
q235817
Assets.jsCall
train
public static function jsCall($file, $nest) { if (strpos($file, 'http://') !== false) { $path = $file.'.js'; } else { if ($nest) { $file = str_replace('.', '/', $file); $path = path().'assets/js/'.$file.'.js'; } else { ...
php
{ "resource": "" }
q235818
ModuleService.defaultConfig
train
public function defaultConfig($name) { $config = $this->config(); $default = array_key_exists('default', $config) ? $config['default'] : array(); if (!array_key_exists($name, $default)) { return array(); } return $default[$name]; }
php
{ "resource": "" }
q235819
ModuleService.lazySet
train
public function lazySet(array $sets) { $config = $this->config(); if (!array_key_exists('lazy-set', $config) || !is_array($config['lazy-set'])) { throw new \Exception('Config with key "lazy-set" does not exist or incorrect data type given in '.__NAMESPACE__); } $lazySetC...
php
{ "resource": "" }
q235820
_File.closeFile
train
private function closeFile() { $this->filename = NULL; if ($this->fh !== NULL && $this->fh !== FALSE) { $rc = fclose($this->fh); return $rc; } else { return TRUE; } }
php
{ "resource": "" }
q235821
ShortMethodsTrait.dn_
train
public function dn_($domain, $singular, $plural, $count) { return $this->dngettext($domain, $singular, $plural, $count); }
php
{ "resource": "" }
q235822
ShortMethodsTrait.dnp_
train
public function dnp_($domain, $context, $singular, $plural, $count) { return $this->dnpgettext($domain, $context, $singular, $plural, $count); }
php
{ "resource": "" }
q235823
ShortMethodsTrait.np_
train
public function np_($context, $singular, $plural, $count) { return $this->npgettext($context, $singular, $plural, $count); }
php
{ "resource": "" }
q235824
DbRepository.find
train
public function find($column, $value) { return $this->getFirst((is_null($column) ? $this->key : $column) . ' = ?', [$value]); }
php
{ "resource": "" }
q235825
DbRepository.getFirst
train
public function getFirst($conditions = null, $values = [], $options = []) { return $this->processSingleResult($this->executeQuery(null, $conditions, $values, $options)); }
php
{ "resource": "" }
q235826
DbRepository.getAll
train
public function getAll($conditions = null, $values = [], $options = []) { return $this->processMultipleResults($this->executeQuery(null, $conditions, $values, $options)); }
php
{ "resource": "" }
q235827
DbRepository.save
train
public function save($model) { if (isset($model->{$this->key})) { return $this->update($model); } return $this->create($model); }
php
{ "resource": "" }
q235828
DbRepository.delete
train
public function delete($model) { $this->db->connect() ->deleteFrom($this->table) ->where($this->key . ' = ?') ->execute([$model->{$this->key}]); $model->{$this->key} = null; }
php
{ "resource": "" }
q235829
DbRepository.count
train
public function count($conditions = null, $values = []) { $res = $this->executeQuery('COUNT(' . $this->key . ') AS num', $conditions, $values) ->fetch(); return (isset($res->num) ? (int)$res->num : 0); }
php
{ "resource": "" }
q235830
DbRepository.executeQuery
train
protected function executeQuery($select = null, $conditions = null, $values = [], $options = []) { $query = $this->db->connect(); if (!empty($this->fetchRefs)) { $query = $this->setupJoin($query, $select, $conditions, (isset($options['order']) ? $options['order'] : null)); } else...
php
{ "resource": "" }
q235831
DbRepository.populateModelFromJoin
train
protected function populateModelFromJoin($result) { // extract main model $model = new $this->modelClass(); foreach (array_keys(get_object_vars($model)) as $attr) { $model->$attr = $result->$attr; } // extract referenced models $refs = $model->get...
php
{ "resource": "" }
q235832
DbRepository.processSingleResult
train
protected function processSingleResult($query) { if (!empty($this->fetchRefs)) { $res = $query->fetch(); $model = ($res ? $this->populateModelFromJoin($res) : $res); } else { $model = $query->fetchClass($this->modelClass); } if ($model && isset($th...
php
{ "resource": "" }
q235833
DbRepository.processMultipleResults
train
protected function processMultipleResults($query) { if (!empty($this->fetchRefs)) { $models = []; foreach ($query->fetchAll() as $model) { $models[] = $this->populateModelFromJoin($model); } } else { $models = $query->fetchAllClass($thi...
php
{ "resource": "" }
q235834
DbRepository.setupJoin
train
private function setupJoin($query, $select, $conditions, $order = null) { // find references $model = new $this->modelClass(); $refs = $model->getReferences(); if (is_array($this->fetchRefs)) { $refs = array_intersect_key($refs, array_flip($this->fetchRefs)); } ...
php
{ "resource": "" }
q235835
DbRepository.prefixModelAttributes
train
private function prefixModelAttributes($input, $model) { foreach (array_keys(get_object_vars($model)) as $attr) { $input = preg_replace('/\\b' . $attr . '\\b/', $this->table . ".$attr", $input); } return $input; }
php
{ "resource": "" }
q235836
DbRepository.create
train
private function create($model) { $attrs = $this->getMutableAttributes($model); $this->db ->connect() ->insert($this->table, array_keys($attrs)) ->execute(array_values($attrs)); $model->{$this->key} = $this->db->lastInsertId(); }
php
{ "resource": "" }
q235837
DbRepository.update
train
private function update($model) { $attrs = $this->getMutableAttributes($model); $values = array_values($attrs); $values[] = $model->{$this->key}; $this->db ->connect() ->update($this->table, array_keys($attrs)) ->where($this->key . ' = ?') ...
php
{ "resource": "" }
q235838
DbRepository.getMutableAttributes
train
private function getMutableAttributes($model) { $attrs = get_object_vars($model); unset($attrs[$this->key]); // remove reference attributes, if any if ($model instanceof ManagedModelInterface) { foreach (array_keys($model->getReferences()) as $ref) { ...
php
{ "resource": "" }
q235839
Component.set
train
public function set($property, $name, $value = null) { $set = (is_array($name)) ? $name : array($name => $value); switch ($property) { case 'errors': $this->validator->errors = array_merge($this->validator->errors, $set); break; case 'values': ...
php
{ "resource": "" }
q235840
Component.close
train
public function close() { $html = implode('', $this->footer); foreach ($this->hidden as $key => $value) { $html .= "\n\t".$this->input('hidden', array( 'name' => $key, 'value' => htmlspecialchars((string) $value), )); } return ...
php
{ "resource": "" }
q235841
Component.validate
train
public function validate($field, array $attributes = array()) { foreach ($this->validator->rules($field) as $validate => $param) { $attributes["data-rule-{$validate}"] = htmlspecialchars($param); } foreach ($this->validator->messages($field) as $rule => $message) { $a...
php
{ "resource": "" }
q235842
Component.flatten
train
private function flatten(array $array) { $single = array(); if (isset($array['hier'])) { unset($array['hier']); } foreach ($array as $key => $value) { if (is_array($value)) { foreach ($this->flatten($value) as $key => $value) { ...
php
{ "resource": "" }
q235843
Bencode.encode
train
public function encode($d) { if (is_array($d)) { $def = 'd'; $s = ''; // If first array key is an integer, assume list. $list = false; if (is_int(array_keys($d)[0])) { $list = true; $def = 'l'; } ksort($d, SORT_STRING); foreach ($d as $key => $value) { if (is_string($key)) { ...
php
{ "resource": "" }
q235844
Bencode.decode
train
public function decode($d, &$pos = 0) { if (!is_string($d)) { throw new Exception('Tried to decode non-string data.', 1); } if (strlen($d) <= $pos) { return null; } switch ($d[$pos]) { case 'd': $ret = []; $pos++; while ($d[$pos] != 'e') { $key = $this->decode($d, $pos); ...
php
{ "resource": "" }
q235845
Result.getFields
train
protected function getFields()/*# : bool */ { if (null === $this->cols) { $result = $this->statement->result_metadata(); if (false === $result) { return false; } $this->cols = []; // set column name foreach ($result->f...
php
{ "resource": "" }
q235846
Plugin.load
train
public function load() { if( $this->cacheType() === "data" ) { $ref = new \ReflectionClass($this); $cache_name = Str::snake($ref->getShortName()); $cache_data = $this->cacheData(); if( isset($cache_data["id"]) ) { $id = $cache_data["id"]; unset($cache_data["id"]); } else { $id ...
php
{ "resource": "" }
q235847
Directory.hasChildren
train
public function hasChildren() { if ($this->resources === null) { $this->initializeResouces(); } return current($this->resources) instanceof \Arbit\VCSWrapper\Directory; }
php
{ "resource": "" }
q235848
Notifier.addChannel
train
public function addChannel(ChannelInterface $channel) { $this->getChannelStore() ->addChannel($channel); $processor = $channel->getProcessor(); if ($processor) { $this->getProcessorStore()->addProcessor($processor); } }
php
{ "resource": "" }
q235849
Notifier.sendMessage
train
public function sendMessage(MessageInterface $message, array $recipients) { $messageProcessor = new MessageProcessor($this->getProcessorStore()); $message = $messageProcessor->preProcessMessage($message); foreach ($recipients as $recipient) { foreach ($this->getChannels($message...
php
{ "resource": "" }
q235850
Notifier.getChannels
train
private function getChannels(MessageInterface $message, RecipientInterface $recipient) { $channels = $this->channelResolver ->getChannels($message->getType(), $this->getChannelStore()); return $this->channelResolver ->filterChannels($recipient, $message->getType(), $channels...
php
{ "resource": "" }
q235851
Hash.reject
train
public function reject(Closure $callback) { $hash = $this->create(); foreach ($this as $key => $value) { if ($callback($value, $key) == false) { $hash[$key] = $value; } } return $hash; }
php
{ "resource": "" }
q235852
Hash.map
train
public function map(Closure $callback) { $hash = $this->create(); $this->each(function ($value, $key) use ($callback, $hash) { $hash[] = $callback($value, $key); }); return $hash; }
php
{ "resource": "" }
q235853
Hash.fetch
train
public function fetch($key, $default = null) { if ($this->hasKey($key)) { return $this[$key]; } elseif ($default !== null) { if (is_callable($default)) { return $default($key); } return $default; } throw new InvalidArg...
php
{ "resource": "" }
q235854
Hash.valuesAt
train
public function valuesAt() { $args = func_get_args(); if (is_array($args[0])) { $args = $args[0]; } $hash = $this->create(); foreach ($args as $key) { $hash[] = $this[$key]; } return $hash; }
php
{ "resource": "" }
q235855
Hash.groupBy
train
public function groupBy($criteria) { $criteria = $this->factoryCallableCriteria($criteria); $groups = $this->create(); $this->each(function ($element, $key) use ($groups, $criteria) { $groupName = $criteria($element, $key); $elements = $groups->offsetGet($groupN...
php
{ "resource": "" }
q235856
Hash.sortBy
train
public function sortBy($criteria) { $criteria = $this->factoryCallableCriteria($criteria); $sorted = $this->create(); $groups = $this->groupBy($criteria); $criterias = $this->map(function ($element, $key) use ($criteria) { return $criteria($element, $key); })...
php
{ "resource": "" }
q235857
Hash.factoryCallableCriteria
train
private function factoryCallableCriteria($criteria) { if (!$this->isCallable($criteria)) { $criteria = function ($element, $key) use ($criteria) { return $element->fetch($criteria); }; } return $criteria; }
php
{ "resource": "" }
q235858
Hash.merge
train
public function merge(Hash $other, Closure $closure = null) { return $this->mergeInto(clone $this, $other, $closure); }
php
{ "resource": "" }
q235859
Base.minimize
train
public function minimize() { foreach (get_object_vars($this) as $property => $value) { if ($value instanceof self) { $value->minimize(); } elseif (is_array($value)) { $this->minimizeArray($value); } } return $this; }
php
{ "resource": "" }
q235860
Base.sort
train
public function sort( array $defaultOrder, array $controlsOrder = null, array $metaOrder = null, array $errorOrder = null ) { if (!in_array('{data}', $defaultOrder)) { throw new \InvalidArgumentException('Placeholder "{data}" not listed in $defaultOrder'); ...
php
{ "resource": "" }
q235861
Ajax.handle
train
public function handle() { if (! $this->is_ajax_request()) { return Handler::DONE; } $response = [ 'success' => false, 'data' => Formatter::formatExceptionAsDataArray($this->getInspector(), $this->addTraceToOutput()), ]; if (Misc::canS...
php
{ "resource": "" }
q235862
StatementMYSQL.executeQuery
train
public function executeQuery(): IResultSet { if (!strlen($this->sql) > 0) { throw new \Exception('Error sentencia sql no valida'); } $temp = $this->conect->query($this->sql); $this->sql = ""; if ($temp == null) { throw new \Excep...
php
{ "resource": "" }
q235863
Query.executeDelete
train
public function executeDelete(EntityMetadata $metadata, Store $store, array $criteria) { $criteria = $this->getFormatter()->formatQuery($metadata, $store, $criteria); return $this->createQueryBuilder($metadata) ->remove() ->setQueryArray($criteria) ->getQuery() ...
php
{ "resource": "" }
q235864
Query.executeFind
train
public function executeFind(EntityMetadata $metadata, Store $store, array $criteria, array $fields = [], array $sort = [], $offset = 0, $limit = 0) { $criteria = $this->getFormatter()->formatQuery($metadata, $store, $criteria); $builder = $this->createQueryBuilder($metadata) ->find() ...
php
{ "resource": "" }
q235865
Query.executeInsert
train
public function executeInsert(EntityMetadata $metadata, array $toInsert) { return $this->createQueryBuilder($metadata) ->insert() ->setNewObj($toInsert) ->getQuery() ->execute() ; }
php
{ "resource": "" }
q235866
Query.executeUpdate
train
public function executeUpdate(EntityMetadata $metadata, Store $store, array $criteria, array $toUpdate) { $criteria = $this->getFormatter()->formatQuery($metadata, $store, $criteria); return $this->createQueryBuilder($metadata) ->update() ->setQueryArray($criteria) ...
php
{ "resource": "" }
q235867
Query.getInverseCriteria
train
public function getInverseCriteria(EntityMetadata $owner, EntityMetadata $related, $identifiers, $inverseField) { $criteria = [ $inverseField => (array) $identifiers, ]; if (true === $related->isChildEntity()) { // The relationship is owned by a polymorphic model. M...
php
{ "resource": "" }
q235868
Query.getModelCollection
train
public function getModelCollection(EntityMetadata $metadata) { if (!$metadata->persistence instanceof StorageMetadata) { throw PersisterException::badRequest('Wrong StorageMetadata type'); } return $this->connection->selectCollection($metadata->persistence->db, $metadata->persist...
php
{ "resource": "" }
q235869
Query.getRetrieveCritiera
train
public function getRetrieveCritiera(EntityMetadata $metadata, $identifiers = null) { $criteria = []; if (true === $metadata->isChildEntity()) { $criteria[Persister::POLYMORPHIC_KEY] = $metadata->type; } elseif (true === $metadata->isPolymorphic() && false === $metadata->isAbstrac...
php
{ "resource": "" }
q235870
Query.appendFields
train
private function appendFields(QueryBuilder $builder, array $fields) { list($fields, $include) = $this->prepareFields($fields); if (!empty($fields)) { $method = (true === $include) ? 'select' : 'exclude'; $builder->$method(array_keys($fields)); } return $this; ...
php
{ "resource": "" }
q235871
Query.appendLimitAndOffset
train
private function appendLimitAndOffset(QueryBuilder $builder, $limit, $offset) { $limit = (int) $limit; $offset = (int) $offset; if ($limit > 0) { $builder->limit($limit); } if ($offset > 0) { $builder->skip($offset); } return $this; ...
php
{ "resource": "" }
q235872
Query.appendSearch
train
private function appendSearch(QueryBuilder $builder, array $criteria) { if (false === $this->isSearchQuery($criteria)) { return $this; } $builder->selectMeta('searchScore', 'textScore'); $builder->sortMeta('searchScore', 'textScore'); return $this; }
php
{ "resource": "" }
q235873
Query.appendSort
train
private function appendSort(QueryBuilder $builder, array $sort) { if (!empty($sort)) { $builder->sort($sort); } return $this; }
php
{ "resource": "" }
q235874
Query.isSearchQuery
train
private function isSearchQuery(array $criteria) { if (isset($criteria['$text'])) { return true; } foreach ($criteria as $key => $value) { if (is_array($value) && true === $this->isSearchQuery($value)) { return true; } } retu...
php
{ "resource": "" }
q235875
Query.prepareFields
train
private function prepareFields(array $fields) { $include = null; foreach ($fields as $key => $type) { $type = (bool) $type; if (null === $include) { $include = $type; } if ($type !== $include) { PersisterException::badRe...
php
{ "resource": "" }
q235876
Paginator.getPage
train
public function getPage() { if (empty($this->page) && ($paramName = $this->getParamName()) != '') { $this->setPage(\pwf\basic\Application::$instance->getRequest()->get($paramName)); } return $this->page; }
php
{ "resource": "" }
q235877
PermanentObject.update
train
public function update($input, $fields, &$errCount = 0) { $operation = $this->getUpdateOperation($input, $fields); $operation->validate($errCount); return $operation->runIfValid(); }
php
{ "resource": "" }
q235878
PermanentObject.getUpdateOperation
train
public function getUpdateOperation($input, $fields) { $operation = new UpdateTransactionOperation(static::getClass(), $input, $fields, $this); $operation->setSQLAdapter(static::getSQLAdapter()); return $operation; }
php
{ "resource": "" }
q235879
PermanentObject.onValidUpdate
train
public static function onValidUpdate(&$input, $newErrors) { // Don't care about some errors, other fields should be updated. $found = 0; foreach( $input as $fieldname => $fieldvalue ) { if( in_array($fieldname, static::$fields) ) { $found++; } } if( $found ) { static::fillLogEvent($input, 'edit')...
php
{ "resource": "" }
q235880
PermanentObject.extractUpdateQuery
train
public static function extractUpdateQuery(&$input, PermanentObject $object) { static::onEdit($input, $object); foreach( $input as $fieldName => $fieldValue ) { // If saving object, value is the same, validator should check if value is new if( !in_array($fieldName, static::$fields) ) { unset($input[$fie...
php
{ "resource": "" }
q235881
PermanentObject.save
train
public function save() { if( empty($this->modFields) || $this->isDeleted() ) { return false; } $data = array_filterbykeys($this->data, $this->modFields); if( !$data ) { throw new Exception('No updated data found but there is modified fields, unable to update'); } $operation = $this->getUpdateOperat...
php
{ "resource": "" }
q235882
PermanentObject.remove
train
public function remove() { if( $this->isDeleted() ) { return 0; } $operation = $this->getDeleteOperation(); $errors = 0; $operation->validate($errors); return $operation->runIfValid(); }
php
{ "resource": "" }
q235883
PermanentObject.reload
train
public function reload($field = null) { $IDFIELD = static::getIDField(); $options = array('where' => $IDFIELD . '=' . $this->$IDFIELD, 'output' => SQLAdapter::ARR_FIRST); if( $field ) { if( !in_array($field, static::$fields) ) { throw new FieldNotFoundException($field, static::getClass()); } $i = arr...
php
{ "resource": "" }
q235884
PermanentObject.getValue
train
public function getValue($key = null) { if( empty($key) ) { return $this->data; } if( !array_key_exists($key, $this->data) ) { throw new FieldNotFoundException($key, static::getClass()); } return $this->data[$key]; }
php
{ "resource": "" }
q235885
PermanentObject.setValue
train
public function setValue($key, $value) { if( !isset($key) ) { // Invalid key throw new Exception("nullKey"); } else if( !in_array($key, static::$fields) ) { // Unknown key throw new FieldNotFoundException($key, static::getClass()); } else if( $key === static::$IDFIELD ) { // ID is not edita...
php
{ "resource": "" }
q235886
PermanentObject.equals
train
public function equals($o) { return (get_class($this) == get_class($o) && $this->id() == $o->id()); }
php
{ "resource": "" }
q235887
PermanentObject.getLogEvent
train
public static function getLogEvent($event, $time = null, $ipAdd = null) { return array( $event . '_time' => isset($time) ? $time : time(), $event . '_date' => isset($time) ? sqlDatetime($time) : sqlDatetime(), $event . '_ip' => isset($ipAdd) ? $ipAdd : (!empty($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_AD...
php
{ "resource": "" }
q235888
PermanentObject.isFieldEditable
train
public static function isFieldEditable($fieldName) { if( $fieldName == static::$IDFIELD ) { return false; } if( !is_null(static::$editableFields) ) { return in_array($fieldName, static::$editableFields); } if( method_exists(static::$validator, 'isFieldEditable') ) { return in_array($fieldName, static...
php
{ "resource": "" }
q235889
PermanentObject.get
train
public static function get($options = null) { if( $options === null ) { /** @noinspection PhpIncompatibleReturnTypeInspection */ return static::select(); } if( $options instanceof SQLSelectRequest ) { $options->setSQLAdapter(static::getSQLAdapter()); $options->setIDField(static::$IDFIELD); $options...
php
{ "resource": "" }
q235890
PermanentObject.load
train
public static function load($in, $nullable = true, $usingCache = true) { if( empty($in) ) { if( $nullable ) { return null; } static::throwNotFound('invalidParameter_load'); } // Try to load an object from this class if( is_object($in) && $in instanceof static ) { return $in; } $IDFIELD = sta...
php
{ "resource": "" }
q235891
PermanentObject.checkCache
train
protected function checkCache() { if( isset(static::$instances[static::getClass()][$this->id()]) ) { return static::$instances[static::getClass()][$this->id()]; } static::$instances[static::getClass()][$this->id()] = $this; return $this; }
php
{ "resource": "" }
q235892
PermanentObject.clearDeletedInstances
train
public static function clearDeletedInstances() { if( !isset(static::$instances[static::getClass()]) ) { return; } $instances = &static::$instances[static::getClass()]; foreach( $instances as $id => $obj ) { /* @var static $obj */ if( $obj->isDeleted() ) { unset($instances[$id]); } } }
php
{ "resource": "" }
q235893
PermanentObject.escapeIdentifier
train
public static function escapeIdentifier($identifier = null) { $sqlAdapter = static::getSQLAdapter(); return $sqlAdapter->escapeIdentifier($identifier ? $identifier : static::$table); }
php
{ "resource": "" }
q235894
PermanentObject.getCreateOperation
train
public static function getCreateOperation($input, $fields) { $operation = new CreateTransactionOperation(static::getClass(), $input, $fields); $operation->setSQLAdapter(static::getSQLAdapter()); return $operation; }
php
{ "resource": "" }
q235895
PermanentObject.onValidCreate
train
public static function onValidCreate(&$input, $newErrors) { if( $newErrors ) { static::throwException('errorCreateChecking'); } static::fillLogEvent($input, 'create'); static::fillLogEvent($input, 'edit'); // $input = static::getLogEvent('create') + static::getLogEvent('edit') + $input; return true; }
php
{ "resource": "" }
q235896
PermanentObject.extractCreateQuery
train
public static function extractCreateQuery(&$input) { // To do on Edit static::onEdit($input, null); foreach( $input as $fieldname => $fieldvalue ) { if( !in_array($fieldname, static::$fields) ) { unset($input[$fieldname]); } } $options = array( 'table' => static::$table, 'what' => $inpu...
php
{ "resource": "" }
q235897
PermanentObject.completeFields
train
public static function completeFields($data) { foreach( static::$fields as $fieldname ) { if( !isset($data[$fieldname]) ) { $data[$fieldname] = ''; } } return $data; }
php
{ "resource": "" }
q235898
PermanentObject.checkUserInput
train
public static function checkUserInput($input, $fields = null, $ref = null, &$errCount = 0) { if( !isset($errCount) ) { $errCount = 0; } // Allow reversed parameters 2 & 3 - Declared as useless // if( !is_array($fields) && !is_object($ref) ) { // $tmp = $fields; $fields = $ref; $ref = $tmp; unset($tmp)...
php
{ "resource": "" }
q235899
PermanentObject.getClassData
train
public static function getClassData(&$classData = null) { $class = static::getClass(); if( !isset(static::$knownClassData[$class]) ) { static::$knownClassData[$class] = (object)array( 'sqlAdapter' => null, ); } $classData = static::$knownClassData[$class]; return $classData; }
php
{ "resource": "" }