_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
33
8k
language
stringclasses
1 value
meta_information
dict
q265900
Bootstrap.getFieldError
test
protected function getFieldError($field, $format = '<span class="help-block">:message</span>') { $field = $this->flattenFieldName($field); if ($this->getErrors()) { $allErrors = $this->config->get('html.bootstrap.show_all_errors'); if ($this->getErrorBag()) { $errorBag = $this->getErrors()->{$this->getErrorBag()}; } else { $errorBag = $this->getErrors();
php
{ "resource": "" }
q265901
Cookie.setSameSite
test
public function setSameSite(string $sameSite = null): self { if (! \in_array($sameSite, [self::LAX, self::STRICT, null], true)) { throw new InvalidSameSiteTypeException( 'The "sameSite" parameter value
php
{ "resource": "" }
q265902
Archive.cleanAndAddHeader
test
protected function cleanAndAddHeader() { if (true === $this->clean || null !== $this->header) { foreach ($this->files as $translation) { $formatter = FormatterFactory::getInstance($translation);
php
{ "resource": "" }
q265903
ClassFinderHelper.findClassesPsr4
test
public static function findClassesPsr4($namespace, $recursively = false, $withoutAutoload = false) { $classNames = []; if(is_array($namespace)) { foreach ($namespace as $ns) { $classNames = ArrayHelper::merge($classNames, static::findClassesPsr4($ns, $recursively, $withoutAutoload)); } return $classNames; } $namespace = trim($namespace, static::CS); list($nsPrefix, $namespacePaths) = static::getNamespacePaths($namespace); if (empty($namespacePaths)) { return []; } $files = []; $regEx = '/\.php$/'; for ($i = 0; $i < count($namespacePaths); $i++) { $dir = $namespacePaths[$i]; $dirIt = new \RecursiveDirectoryIterator($dir); $files = [];
php
{ "resource": "" }
q265904
ClassFinderHelper.getNamespacePath
test
public static function getNamespacePath($namespace, $first = true) { $namespace = trim($namespace, static::CS); $nsPrefixes = static::getNamespacePrefixes($namespace); $loaderPrefixes = static::getLoaderPrefixes(); $nsSuffix = ''; foreach ($nsPrefixes as $prefix) { if (!isset($loaderPrefixes[$prefix])) { continue; } $nsSuffix = trim(mb_substr($namespace, mb_strlen($prefix)), static::CS); $paths = $loaderPrefixes[$prefix]; break; } if (!isset($paths)) { return $first ? null : [];
php
{ "resource": "" }
q265905
ClassFinderHelper.getNamespacePaths
test
protected static function getNamespacePaths($namespace) { $paths = []; $namespace = trim($namespace, static::CS); $nsPrefixes = static::getNamespacePrefixes($namespace); $nsPrefixesCount = count($nsPrefixes); $loaderPrefixes = static::getLoaderPrefixes(); $nsPrefix = null; for ($i = 0; $i < $nsPrefixesCount; $i++) { $nsPrefix = $nsPrefixes[$i]; if (!isset($loaderPrefixes[$nsPrefix])) { continue; } if ($nsPrefix === $namespace) { return $loaderPrefixes[$nsPrefix]; } $nsSuffix = trim(substr($namespace, strlen($nsPrefix)), static::CS); $nsSuffix = str_replace(static::CS, static::DS, $nsSuffix);
php
{ "resource": "" }
q265906
ClassFinderHelper.getNamespacePrefixes
test
protected static function getNamespacePrefixes($namespace) { $namespaceExp = explode(static::CS, trim($namespace, static::CS)); $namespaceExpCount = count($namespaceExp); if ($namespaceExpCount === 1) {
php
{ "resource": "" }
q265907
ClassFinderHelper.getLoaderPrefixes
test
protected static function getLoaderPrefixes() { $loader = static::getLoader(); $_prefixes = [ [], $loader->getPrefixesPsr4(), ]; $_prefixes = ArrayHelper::merge(...$_prefixes);
php
{ "resource": "" }
q265908
FilterComponent.updateSession
test
public function updateSession() { $existingSession = $this->getSession(); if ($this->form) { $filters = $this->form->getData() + $this->filterDefaults(); } else { $filters = $this->filterDefaults(); } $currentValues = [ 'filters'
php
{ "resource": "" }
q265909
FilterComponent.mergeSession
test
public function mergeSession(array $newValues) { $existing = $this->getSession();
php
{ "resource": "" }
q265910
FilterComponent.getSession
test
public function getSession($key = null) { // merge the arrays, using the default values if not in the session $sessionData = (array) $this->session->get($this->sessionKey) + $this->sessionDefaults(); if (null === $key) { return $sessionData;
php
{ "resource": "" }
q265911
FilterComponent.pageFromQuery
test
public function pageFromQuery() { if ($this->request) { $page = $this->request->query->getInt('page'); } else {
php
{ "resource": "" }
q265912
FilterComponent.query
test
public function query() { $queryData = [ self::FORM_BLOCK_NAME => $this->getFiltersAsArray(), 'page'
php
{ "resource": "" }
q265913
FilterComponent.getFiltersAsArray
test
protected function getFiltersAsArray() { $filters = $this->getSession('filters'); foreach ($filters as $key => $value) { if ($value instanceof ArrayCollection) { $filters[$key] = $filters[$key]->map( function ($entity) { return $entity->getId(); } )->toArray(); } else if (is_array($value)) { foreach
php
{ "resource": "" }
q265914
FilterComponent.createForm
test
public function createForm(array $formOptions = []) { $defaults = $this->filterDefaults(); $this->form = $this->formFactory->create( $this->formType, $defaults,
php
{ "resource": "" }
q265915
FilterComponent.storeResult
test
public function storeResult($idOnlyQb) { $result = $idOnlyQb->getQuery()->getArrayResult();
php
{ "resource": "" }
q265916
FilterComponent.getPagination
test
public function getPagination($query) { $pagination = $this->paginator->paginate( $query, $this->pageFromQuery(),
php
{ "resource": "" }
q265917
FilterComponent.prevNext
test
public function prevNext($currentRecordId) { $recordIds = (array) $this->getSession('ids'); $prevRecordId = $nextRecordId = null; $currentKey = array_search($currentRecordId, $recordIds); if (false
php
{ "resource": "" }
q265918
Module.toArray
test
public function toArray() { return [ 'icon' => $this->icon, 'title' => $this->title, 'subtitle' => $this->subtitle,
php
{ "resource": "" }
q265919
Module.addField
test
private function addField(array $args, $type = null) { if (count($args) !== 2) { throw new InvalidFieldParametersException('You need pass only name, and title parameters to field'); }
php
{ "resource": "" }
q265920
AbstractDBALCommand.processOptions
test
protected function processOptions(InputInterface $input) { if ($this->getContainer()->offsetExists('dbs')) { $params = $this->getContainer()['dbs'][$input->getOption('connection')] ->getParams(); $this->getHelperSet()->set( new ConnectionHelper( $this->getContainer()['dbs'][$input->getOption('connection')], 'db' ) ); } else {
php
{ "resource": "" }
q265921
AbstractDBALCommand.getConnectionParams
test
protected function getConnectionParams($connectionName = null) { return ($connectionName != null
php
{ "resource": "" }
q265922
SqliteAdapter.isInstalled
test
public function isInstalled($db_name) { if (empty($dbname)) $dbname='default'; return
php
{ "resource": "" }
q265923
Select.getSql
test
public function getSql() { if ($this->adapter === null) { $msg = __METHOD__ . ": Error, prior to use execute method you must provide a valid database adapter. See Select::setDbAdapter() method.";
php
{ "resource": "" }
q265924
Select.execute
test
public function execute() { if ($this->adapter === null) { $msg = __METHOD__ . ": Error, prior to use execute method you must provide a valid database adapter. See Select::setDbAdapter() method."; throw new Exception\InvalidUsageException($msg); } $sql = new Sql($this->adapter); $sql_string = $sql->getSqlStringForSqlObject($this); //return $this->adapter->createStatement($sql_string)->execute(); //return
php
{ "resource": "" }
q265925
NativeEntityManager.getRepository
test
public function getRepository(string $entity): Repository { if (isset($this->repositories[$entity])) { return $this->repositories[$entity];
php
{ "resource": "" }
q265926
NativeEntityManager.create
test
public function create(Entity $entity): void {
php
{ "resource": "" }
q265927
NativeEntityManager.save
test
public function save(Entity $entity): void { $id = spl_object_id($entity);
php
{ "resource": "" }
q265928
NativeEntityManager.remove
test
public function remove(Entity $entity): bool { // Get the id of the object $id = spl_object_id($entity); // If the model is set to be created if (isset($this->createModels[$id])) { // Unset it unset($this->createModels[$id]); return true; } // If the model is set to be saved if (isset($this->saveModels[$id])) {
php
{ "resource": "" }
q265929
NativeEntityManager.commit
test
public function commit(): bool { // Iterate through the models awaiting creation foreach ($this->createModels as $cid => $createModel) { // Create the model $this->getRepository(\get_class($createModel))->create($createModel); // Unset the model
php
{ "resource": "" }
q265930
NativeEntityManager.getStore
test
protected function getStore(string $name = null): PDO { $name = $name ?? $this->app->config()['database']['default']; if (isset($this->stores[$name])) { return $this->stores[$name]; } $config =
php
{ "resource": "" }
q265931
NativeEntityManager.getStoreConfig
test
protected function getStoreConfig(string $name): array { $config = $this->app->config('database.connections.' . $name); if (null === $config) {
php
{ "resource": "" }
q265932
NativeEntityManager.getStoreFromConfig
test
protected function getStoreFromConfig(array $config): PDO { $dsn = $config['driver'] . ':host=' . $config['host'] . ';port=' . $config['port'] . ';dbname=' . $config['database'] . ';charset=' . $config['charset'];
php
{ "resource": "" }
q265933
Password.validate
test
private function validate($password): void { if(strlen($password) < $this->validationMinLength()) { throw new InvalidArgumentException("The password must be at least {$this->validationMinLength()} characters long"); } if(strlen($password) > $this->validationMaxLength()) {
php
{ "resource": "" }
q265934
Accept.from
test
public static function from($accept = null, $acceptLanguage = null, $acceptEncoding = null, $acceptCharset = null) { $medias = static::parse($accept, '/'); $languages = static::parse($acceptLanguage, '-');
php
{ "resource": "" }
q265935
Accept.parse
test
protected static function parse($string, $separator = null) { $items = []; if($string) { $string = strtolower(str_replace(' ', '', $string)); $rows = explode(',', $string); foreach($rows as $row) { @list($item, $quality) = explode(';q=', $row); if(!$quality) {
php
{ "resource": "" }
q265936
Accept.compare
test
protected static function compare($needle, array $haystack) { foreach($haystack as $row)
php
{ "resource": "" }
q265937
Earth.earthRadius
test
public function earthRadius($latitude) { $radLat = deg2rad($latitude); $x = cos($radLat) / $this->earthRadiusSemimajor(); $y = sin($radLat)
php
{ "resource": "" }
q265938
Earth.convertDecToDMS
test
public function convertDecToDMS($coordinate) { $dms = array(); $parts = explode('.', $coordinate); // The degrees portion. $dms['degrees'] = $parts[0]; // Calculate the minutes $temp = ("0."
php
{ "resource": "" }
q265939
Earth.convertDMStoDec
test
public function convertDMStoDec($degrees, $minutes, $seconds) { if ($degrees < 0) { return $degrees - ((($minutes * 60) + $seconds) / 3600); }
php
{ "resource": "" }
q265940
ErrorException.productionRendering
test
public function productionRendering() { $args = array('message'=>$this->getAppMessage()); $ft = CarteBlanche::getContainer()->get('front_controller');
php
{ "resource": "" }
q265941
ErrorException.debugRendering
test
public function debugRendering() { $args = array('message'=>$this->getAppMessage()); $ft = CarteBlanche::getContainer()->get('front_controller');
php
{ "resource": "" }
q265942
ErrorException.log
test
public function log() { CarteBlanche::log( $this->getAppMessage()."\n".$this->getTraceAsString(),
php
{ "resource": "" }
q265943
MessageController.actionConfig
test
public function actionConfig(RequestApplicationInterface $app, $filePath) { $filePath = Reaction::getAlias($filePath); if (file_exists($filePath)) { $confirmPromise = $this->confirm("File '{$filePath}' already exists. Do you wish to overwrite it?"); } else { $confirmPromise = resolve(true); } return $confirmPromise ->then(function() use ($filePath) { $array = VarDumper::export($this->getOptionValues($this->getCurrentAction())); $content = <<<EOD <?php /** * Configuration file for 'console {$this->getUniqueId()}/{$this->defaultAction}' command. * * This file is automatically generated by 'console {$this->getUniqueId()}/{$this->getCurrentAction()}' command. * It contains parameters for source
php
{ "resource": "" }
q265944
MessageController.actionConfigTemplate
test
public function actionConfigTemplate(RequestApplicationInterface $app, $filePath) { $filePath = Reaction::getAlias($filePath); if (file_exists($filePath)) { $confirmPromise = $this->confirm("File '{$filePath}' already exists. Do you wish to overwrite it?"); } else { $confirmPromise = resolve(true); } return $confirmPromise ->then(function() use ($filePath) { if (!copy(Reaction::getAlias('@reaction/Views/message/config.php'), $filePath)) {
php
{ "resource": "" }
q265945
MessageController.saveMessagesToPHP
test
protected function saveMessagesToPHP($messages, $dirName, $overwrite, $removeUnused, $sort, $markUnused) { $promises = []; foreach ($messages as $category => $msgs) { $file = str_replace('\\', '/', "$dirName/$category.php"); $path = dirname($file); $msgs = array_values(array_unique($msgs)); $coloredFileName = Console::ansiFormat($file, [Console::FG_CYAN]); $this->stdout("Saving messages to $coloredFileName...\n"); $promises[]
php
{ "resource": "" }
q265946
MessageController.saveMessagesToPOT
test
protected function saveMessagesToPOT($messages, $dirName, $catalog) { $file = str_replace('\\', '/', "$dirName/$catalog.pot"); FileHelper::createDirectory(dirname($file), $this->filesystemMode); $this->stdout("Saving messages to $file...\n"); $poFile = new GettextPoFile(); $merged = []; $hasSomethingToWrite = false; foreach ($messages as $category => $msgs) { $msgs = array_values(array_unique($msgs));
php
{ "resource": "" }
q265947
TimeBuilder.fromArray
test
public static function fromArray(array $data): Time { if (!isset($data['hours'])) { throw new \InvalidArgumentException('Array is not valid.'); } return new Time(
php
{ "resource": "" }
q265948
TimeBuilder.fromString
test
public static function fromString($time): Time { if (empty($time)) { throw new \InvalidArgumentException('Invalid time "".'); } try { $date = new \DateTime($time); } catch (\Exception $e) { throw new \InvalidArgumentException(\sprintf('Invalid time "%s".', $time), 0, $e);
php
{ "resource": "" }
q265949
TimeBuilder.fromDate
test
public static function fromDate(\DateTime $date): Time { return new
php
{ "resource": "" }
q265950
TimeBuilder.fromSeconds
test
public static function fromSeconds(int $seconds): Time { if ($seconds < 0 || $seconds > 86400) { throw new \InvalidArgumentException(\sprintf('Invalid time "%s".', $seconds)); } $data = [
php
{ "resource": "" }
q265951
TagManager.invalidateTags
test
public function invalidateTags($tags) { if (empty($tags) || !$this->isEnabled()) { return; } $tags = $this->encodeTags($tags); foreach ($tags as $tag) {
php
{ "resource": "" }
q265952
TagManager.flush
test
public function flush() { if (!empty($this->invalidateTags)) { $this->tagHandler->invalidateTags($this->invalidateTags);
php
{ "resource": "" }
q265953
TagManager.encodeTags
test
private function encodeTags($tags) { if (!is_array($tags)) { $tags = array($tags); } if ($this->config['tag']['encode']) { $tmp = []; foreach ($tags as $tag) {
php
{ "resource": "" }
q265954
Config.register
test
public function register() { $namespace = $this->package->getNamespace(); $config = $this->app->make('config'); try { $path = $this->getPath() . '/config.php'; if($this->app->environment() === 'testing') { if( ! $this->filesystem->exists($path)) { return $config->set([ $namespace => $this->getOptions() ]); } } return
php
{ "resource": "" }
q265955
Cookies.all
test
public function all(bool $asString = true): array { if (! $asString) { return $this->cookies; } $flattenedCookies = []; /** @var array $path */ foreach ($this->cookies as $path) {
php
{ "resource": "" }
q265956
Cookies.set
test
public function set(Cookie $cookie): self { $this->cookies[$cookie->getDomain()][$cookie->ge
php
{ "resource": "" }
q265957
Cookies.remove
test
public function remove(string $name, string $path = '/', string $domain = null): self { $path = $path ?? '/'; unset($this->cookies[$domain][$path][$name]); if (empty($this->cookies[$domain][$path])) { unset($this->cookies[$domain][$path]);
php
{ "resource": "" }
q265958
PEAR_Frontend_CLI.confirmDialog
test
function confirmDialog($params) { $answers = $prompts = $types = array(); foreach ($params as $param) { $prompts[$param['name']] = $param['prompt']; $types[$param['name']] = $param['type']; $answers[$param['name']] = isset($param['default']) ? $param['default'] : ''; } $tried = false; do {
php
{ "resource": "" }
q265959
AbstractPostType.getLabels
test
protected function getLabels() { $pluralName = $this->getPluralName(); $singularName = $this->getSingularName(); return array( 'name' => $singularName, 'singular_name' => $singularName, 'add_new' => 'Add New', 'add_new_item' => 'Add New ' . $singularName, 'edit_item' => 'Edit ' . $singularName, 'new_item' => 'New ' . $singularName, 'all_items' => 'All ' . $pluralName, 'view_item' => 'View ' . $singularName,
php
{ "resource": "" }
q265960
LivePubControllerHooks.WrappedSession
test
public function WrappedSession() { LivePubHelper::require_session();
php
{ "resource": "" }
q265961
ConstraintFinderTrait.getTablePrimaryKey
test
public function getTablePrimaryKey($name, $refresh = false) {
php
{ "resource": "" }
q265962
ConstraintFinderTrait.getTableForeignKeys
test
public function getTableForeignKeys($name, $refresh = false) {
php
{ "resource": "" }
q265963
ConstraintFinderTrait.getTableIndexes
test
public function getTableIndexes($name, $refresh = false) { return
php
{ "resource": "" }
q265964
ConstraintFinderTrait.getTableUniques
test
public function getTableUniques($name, $refresh = false) { return
php
{ "resource": "" }
q265965
ConstraintFinderTrait.getTableChecks
test
public function getTableChecks($name, $refresh = false) { return
php
{ "resource": "" }
q265966
ConstraintFinderTrait.getTableDefaultValues
test
public function getTableDefaultValues($name, $refresh = false) {
php
{ "resource": "" }
q265967
ParameterRepository.get
test
public function get($key) { return $this->container->hasParameter($key)
php
{ "resource": "" }
q265968
OmacTrait.checkAccess
test
protected function checkAccess($permission, $arguments = '') { if ( $this->acl === false )
php
{ "resource": "" }
q265969
SelectQuery.distinct
test
public function distinct(bool $enable = true) { $this->changed = true;
php
{ "resource": "" }
q265970
SelectQuery.columns
test
public function columns(string ...$column) { $this->changed = true;
php
{ "resource": "" }
q265971
SelectQuery.join
test
public function join(string $table, array $on) { $this->changed = true;
php
{ "resource": "" }
q265972
SelectQuery.innerJoin
test
public function innerJoin(string $table, array $on) { $this->changed = true;
php
{ "resource": "" }
q265973
SelectQuery.leftJoin
test
public function leftJoin(string $table, array $on) { $this->changed = true;
php
{ "resource": "" }
q265974
SelectQuery.leftOuterJoin
test
public function leftOuterJoin(string $table, array $on) { $this->changed = true;
php
{ "resource": "" }
q265975
SelectQuery.rightJoin
test
public function rightJoin(string $table, array $on) { $this->changed = true;
php
{ "resource": "" }
q265976
SelectQuery.outerJoin
test
public function outerJoin(string $table, array $on) { $this->changed = true;
php
{ "resource": "" }
q265977
SelectQuery.fullOuterJoin
test
public function fullOuterJoin(string $table, array $on) { $this->changed = true;
php
{ "resource": "" }
q265978
SelectQuery.groupBy
test
public function groupBy(string ...$field) { $this->changed = true;
php
{ "resource": "" }
q265979
SelectQuery.andHaving
test
public function andHaving(array $conditions) { $this->changed = true; $this->having = [ 'AND',
php
{ "resource": "" }
q265980
SelectQuery.orHaving
test
public function orHaving(array $conditions) { $this->changed = true;
php
{ "resource": "" }
q265981
SelectQuery.orderBy
test
public function orderBy(string ...$field) { $this->changed = true;
php
{ "resource": "" }
q265982
SelectQuery.limit
test
public function limit(int $limit, int $offset = null) { $this->changed = true; $this->limit = $limit;
php
{ "resource": "" }
q265983
SelectQuery.offset
test
public function offset(int $offset) { $this->changed = true;
php
{ "resource": "" }
q265984
SelectQuery.build
test
protected function build() { if (!$this->from) { throw new \RuntimeException("No tables provided for FROM clause"); } $this->placeholders = []; $this->placeholderCounter = 1; $sql = ['SELECT']; if ($this->distinct) { $sql[] = 'DISTINCT'; } $sql[] = implode(', ', $this->columns); $sql[] = 'FROM'; $sql[] = implode(', ', $this->from); if ($this->joins) { foreach ($this->joins as $join) { $sql[] = $join[0]; $sql[] = $join[1]; $sql[] = 'ON'; $sql[] = is_string($join[2]) ? $join[2] : $this->buildConditions($join[2], false); } } if ($this->conditions) { $sql[] = 'WHERE'; $sql[] = $this->buildConditions($this->conditions); } if ($this->groupBy) { $sql[] = 'GROUP BY'; $sql[] = implode(', ', $this->groupBy); } if ($this->having) {
php
{ "resource": "" }
q265985
UiExtension.renderLink
test
public function renderLink($href, $label = '', array $options = [], array $attributes = []) { $options['type'] = 'link';
php
{ "resource": "" }
q265986
UiExtension.renderButton
test
public function renderButton($label = '', array $options = [], array $attributes = []) { $options = $this->getButtonOptionsResolver()->resolve($options); $tag = 'button'; $classes = ['btn', 'btn-'.$options['theme'], 'btn-'.$options['size']]; $defaultAttributes = [ 'class' => sprintf('btn btn-%s btn-%s', $options['theme'], $options['size']), ]; if ($options['type'] == 'link') { if (0 == strlen($options['path'])) { throw new \InvalidArgumentException('"path" option must be defined for "link" button type.'); } $tag = 'a'; $defaultAttributes['href'] = $options['path']; } else { $defaultAttributes['type'] = $options['type']; } if (array_key_exists('class', $attributes)) { $classes = array_merge($classes, explode(' ', $attributes['class'])); unset($attributes['class']); } $defaultAttributes['class'] = implode(' ', $classes);
php
{ "resource": "" }
q265987
UiExtension.renderLocaleSwitcher
test
public function renderLocaleSwitcher($attributes = []) { // TODO Check if this is a (esi) sub request, as this must never be used in a esi fragment. if (null === $request = $this->requestStack->getCurrentRequest()) { return ''; } if (!array_key_exists('class', $attributes)) {
php
{ "resource": "" }
q265988
Line.__equationToString
test
public function __equationToString() { $str = ''; $a = $this->getSlope(); if ($a!=1) { $str .= "({$a} * x)"; } else { $str .= "x";
php
{ "resource": "" }
q265989
Line.getOrdinateByAbscissa
test
public function getOrdinateByAbscissa($x) { if ($this->isHorizontal()) { return $this->getPointA()->getOrdinate();
php
{ "resource": "" }
q265990
Line.getAbscissaByOrdinate
test
public function getAbscissaByOrdinate($y) { if ($this->isVertical()) { return $this->getPointA()->getAbscissa(); }
php
{ "resource": "" }
q265991
Table.findOrFail
test
public function findOrFail($id) { $record = $this->find($id); if ($record === false) { throw new Exception\NotFoundException(__METHOD__ . ": cannot
php
{ "resource": "" }
q265992
Table.findOneByOrFail
test
public function findOneByOrFail($predicate, $combination = Predicate\PredicateSet::OP_AND) { $record = $this->findOneBy($predicate, $combination); if ($record === false) {
php
{ "resource": "" }
q265993
Table.exists
test
public function exists($id) { $result = $this->select()->where($this->getPrimaryKeyPredicate($id)) ->columns(['count' => new Expression('count(*)')])
php
{ "resource": "" }
q265994
Table.existsBy
test
public function existsBy($predicate, $combination = Predicate\PredicateSet::OP_AND) { try { $select = $this->select()->where($predicate, $combination) ->columns(['count' => new Expression('count(*)')]);
php
{ "resource": "" }
q265995
Table.deleteBy
test
public function deleteBy($predicate, $combination = Predicate\PredicateSet::OP_AND) { $delete = $this->sql->delete($this->prefixed_table) ->where($predicate, $combination);
php
{ "resource": "" }
q265996
Table.deleteOrFail
test
public function deleteOrFail($id) { $deleted = $this->delete($id); if ($deleted == 0) { throw new Exception\NotFoundException(__METHOD__ . ": cannot
php
{ "resource": "" }
q265997
Table.update
test
public function update($data, $predicate, $combination = Predicate\PredicateSet::OP_AND, $validate_datatypes = false) { $prefixed_table = $this->prefixed_table; if ($data instanceof ArrayObject) { $d = (array) $data; } elseif (is_array($data)) { $d = $data; } else {
php
{ "resource": "" }
q265998
Table.insert
test
public function insert($data, $validate_datatypes = false) { $prefixed_table = $this->prefixed_table; if ($data instanceof \ArrayObject) { $d = (array) $data; } elseif (is_array($data)) { $d = $data; } else { $type = gettype($data); throw new Exception\InvalidArgumentException(__METHOD__ . ": expects data to be array or ArrayObject. Type receive '$type'"); } $this->checkDataColumns($d); if ($validate_datatypes) { $this->validateDatatypes($d); } $insert = $this->sql->insert($prefixed_table); $insert->values($d); $this->executeStatement($insert); $pks = $this->getPrimaryKeys(); // Should never happen, as getPrimaryKeys throws Exception when no pk exists //@codeCoverageIgnoreStart if (!is_array($pks)) { $msg = __METHOD__ . " Error getting primary keys of table " . $this->table . ", require array, returned type is: " . gettype($pks) ; throw new Exception\UnexpectedValueException($msg); } //@codeCoverageIgnoreEnd $nb_pks = count($pks); if ($nb_pks >
php
{ "resource": "" }
q265999
Table.relation
test
public function relation() { if ($this->relation === null) {
php
{ "resource": "" }