search

@param array $criteria

@return array
160929
protected function search(array $criteria = [])
    {
        $configs = $this->getConfigs();

        $result = [];

        foreach ($configs as $config) {
            if ($this->filter($config, $criteria)) {
                $result[] = $config;
            }
        }

        return $result;
    }
1282964
public function getPlainSelectedColumns(Criteria $criteria)
    {
        $selected = [];
        foreach ($criteria->getSelectColumns() as $columnName) {
            if (false === strpos($columnName, '(')) {
                $selected[] = $columnName;
            }
        }

        foreach ($criteria->getAsColumns() as $alias => $col) {
            if (false === strpos($col, '(') && !in_array($col, $selected)) {
                $selected[] = $col;
            }
        }

        return $selected;
    }
427232
public function findBy(array $criteria)
    {
        $found = [];
        foreach ($this->getCollection()->all() as $template) {
            foreach ($criteria as $criterium => $value) {
                $method = 'get'.ucfirst(strtolower($criterium));
                if (!method_exists($template, $method)) {
                    continue;
                }
                if ($template->$method() !== $value) {
                    continue 2;
                }
            }

            $found[] = $template;
        }

        return $found;
    }
512205
public function searchForList($criteria = null)
    {
        if (is_null($criteria)) {
            $criteria = new CDbCriteria;
        }

        $criteria->select = "t.*,ccgr_name,ccxg_ccgr_id";
        $criteria->compare('ccmp_id', $this->ccmp_id);
        $criteria->compare('ccmp_name', $this->ccmp_name, true);
        $criteria->compare('ccmp_ccnt_id', $this->ccmp_ccnt_id);
        $criteria->compare('ccmp_registrtion_no', $this->ccmp_registrtion_no, true);
        $criteria->compare('ccmp_vat_registrtion_no', $this->ccmp_vat_registrtion_no, true);
        $criteria->compare('ccmp_registration_date', $this->ccmp_registration_date);
        $criteria->compare('ccmp_registration_address', $this->ccmp_registration_address, true);
        $criteria->compare('ccmp_official_ccit_id', $this->ccmp_official_ccit_id);
        $criteria->compare('ccmp_official_address', $this->ccmp_official_address, true);
        $criteria->compare('ccmp_official_zip_code', $this->ccmp_official_zip_code, true);
        $criteria->compare('ccmp_office_ccit_id', $this->ccmp_office_ccit_id);
        $criteria->compare('ccmp_office_address', $this->ccmp_office_address, true);
        $criteria->compare('ccmp_office_zip_code', $this->ccmp_office_zip_code, true);
        $criteria->compare('ccmp_statuss', $this->ccmp_statuss);
        $criteria->compare('ccmp_description', $this->ccmp_description, true);
        $criteria->compare('ccmp_office_phone', $this->ccmp_office_phone, true);
        $criteria->compare('ccmp_office_email', $this->ccmp_office_email, true);
        $criteria->compare('ccmp_agreement_nr', $this->ccmp_agreement_nr, true);
        $criteria->compare('ccmp_agreement_date', $this->ccmp_agreement_date);
        $criteria->compare('ccmp_sys_ccmp_id', $this->ccmp_sys_ccmp_id);        
        $criteria->compare('ccxg_ccgr_id', $this->ccxg_ccgr_id);        

        $criteria->join  = " 
        LEFT OUTER JOIN ccxg_company_x_group 
            ON ccxg_ccmp_id = ccmp_id 
        LEFT OUTER JOIN ccgr_group 
            ON ccxg_ccgr_id = ccgr_id 
                   
        ";

        return new CActiveDataProvider('CcmpCompany', array(
            'criteria' => $criteria,
             'sort'=>array('defaultOrder'=>'ccmp_name'),
             'pagination'=>array('pageSize'=>50),

        ));        
    }
890037
private function expandCriteriaParameters(Criteria $criteria)
    {
        $expression = $criteria->getWhereExpression();

        if ($expression === null) {
            return [];
        }

        $valueVisitor = new SqlValueVisitor();

        $valueVisitor->dispatch($expression);

        [, $types] = $valueVisitor->getParamsAndTypes();

        return $types;
    }
296903
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($groupName, array());
            $elements[] = $element;
            $groups[$groupName] = $elements;
        });

        return $groups;
    }
836099
public function findBy(array $criteria, ?array $sorting = null, $limit = null, $offset = null)
    {
        $queryBuilder = $this->getCollectionQueryBuilder();

        $this->applyCriteria($queryBuilder, $criteria);
        $this->applySorting($queryBuilder, $sorting);

        if (null !== $limit) {
            $queryBuilder->limit($limit);
        }

        if (null !== $offset) {
            $queryBuilder->skip($offset);
        }

        return $queryBuilder
            ->getQuery()
            ->getIterator()
        ;
    }
262988
public function findOneBy(array $criteria): ?ResourceInterface
    {
        if (empty($criteria)) {
            throw new \InvalidArgumentException('The criteria array needs to be set.');
        }

        $results = $this->applyCriteria($this->findAll(), $criteria);

        if ($result = reset($results)) {
            return $result;
        }

        return null;
    }
790666
public function findRandomOneBy(array $criteria)
    {
        $queryBuilder = $this->getQueryBuilder();

        $this->applyCriteria($queryBuilder, $criteria);

        return $queryBuilder
            ->addSelect('RAND() as HIDDEN rand')
            ->orderBy('rand')
            ->setMaxResults(1)
            ->getQuery()
            ->getOneOrNullResult()
        ;
    }
164370
public function findBy(array $criteria, ?array $sort = null, $limit = null, $skip = null) : array
    {
        return $this->getDocumentPersister()->loadAll($criteria, $sort, $limit, $skip)->toArray();
    }
331387
public function getAll(array $criteria = [])
    {
        $query = sprintf('%s/snapshots?per_page=%d', $this->endpoint, 200);

        if (isset($criteria['type']) && in_array($criteria['type'], ['droplet', 'volume'])) {
            $query = sprintf('%s&resource_type=%s', $query, $criteria['type']);
        }

        $snapshots = $this->adapter->get($query);

        $snapshots = json_decode($snapshots);

        $this->extractMeta($snapshots);

        return array_map(function ($snapshots) {
            return new SnapshotEntity($snapshots);
        }, $snapshots->snapshots);
    }
971796
public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
    {
        $this->preFindBy($criteria);

        $result =  $this->doFindBy($criteria, $orderBy, $limit, $offset);
        $result = $this->postFindBy($result);

        return $result;
    }
90153
public function findOneBy($criteria)
    {
        $this->preFindOneBy();
        $entity =  $this->doFindOneBy($criteria);
        $this->postFindOneBy($entity);

        return $entity;
    }
577591
protected function getSorter(array $criteria)
    {
        $sorter = function ($a, $b) use ($criteria) {
            foreach ($criteria as $orderable) {
                $column    = $this->getColumnName($orderable['column']);
                $direction = $orderable['direction'];
                if ($direction === 'desc') {
                    $first  = $b;
                    $second = $a;
                } else {
                    $first  = $a;
                    $second = $b;
                }
                if ($this->config->isCaseInsensitive()) {
                    $cmp = strnatcasecmp($first[$column], $second[$column]);
                } else {
                    $cmp = strnatcmp($first[$column], $second[$column]);
                }
                if ($cmp != 0) {
                    return $cmp;
                }
            }

            // all elements were equal
            return 0;
        };

        return $sorter;
    }
602043
public function matching(Criteria $criteria)
    {
        $this->guardAgainstInvalidGivenType();
        $elements = $this->collection->matching($criteria)->toArray();

        return $this->create($elements);
    }
886864
public static function findOneByCriteria(array $criteria): ?self
    {
        try {
            list($columns, $values, $options) = static::parseCriteria($criteria);
        } catch (NoTagsException $e) {
            return null;
        }

        if (\count($columns) < 1) {
            return null;
        }

        return static::findOneBy($columns, $values, $options);
    }
1130312
public function seeUserInDatabase(array $criteria)
    {
        $tableName = $this->grabPrefixedTableNameFor('users');
        $allCriteria = $criteria;
        if (!empty($criteria['user_pass'])) {
            $userPass = $criteria['user_pass'];
            unset($criteria['user_pass']);
            $hashedPass = $this->grabFromDatabase($tableName, 'user_pass', $criteria);
            $passwordOk = WpPassword::instance()->check($userPass, $hashedPass);
            $this->assertTrue(
                $passwordOk,
                'No matching records found for criteria ' . json_encode($allCriteria) . ' in table ' . $tableName
            );
        }
        $this->seeInDatabase($tableName, $criteria);
    }