Just a simple wrapper to get_records(), guaranteed to return a single record.

@param $filter			(array) fieldname=>value list of filters.

@RETURN (array)			SUCCESS: returns single record with all fields.
@EXCEPTION 				FAIL: exception indicates error
354537
public function get_single_record(array $filter) {
		if(is_array($filter) && count($filter)) {
			try {
				$data = $this->get_records($filter, null, 1);
				
				if(is_array($data)) {
					$keys = array_keys($data);
					$retval = $data[$keys[0]];
				}
				else {
					//technically, the call to get_records() got boolean(false) from cs_phpDB::run_query(), so we could just return $data directly...
					$retval = false;
				}
			}
			catch(Exception $e) {
				throw new Exception(__METHOD__ .":: failed to retrieve record, DETAILS::: ". $e->getMessage());
			}
		}
		else {
			throw new Exception(__METHOD__ .":: no filter passed");
		}
		
		return($retval);
	}
223740
public static function _($value, $filters = 'raw')
    {
        if (is_string($filters)) {
            $filters = Str::trim($filters);
            $filters = explode(',', $filters);

            if (count($filters) > 0) {
                foreach ($filters as $filter) {
                    $filterName = self::cmd($filter);

                    if ($filterName) {
                        if (method_exists(__CLASS__, $filterName)) {
                            $value = self::$filterName($value);
                        } else {
                            throw new Exception('Undefined filter method: ' . $filter);
                        }
                    }
                }
            }
        } elseif ($filters instanceof \Closure) {
            $value = $filters($value);
        }

        return $value;
    }
1058131
public function filter($filter)
    {
        preg_match_all("/(#\w+)/", $filter, $entityNames);
        preg_match_all("/(:\w+)/", $filter, $positions);

        $entityName = is_array($entityNames[0]) && isset($entityNames[0][0]) ? ltrim($entityNames[0][0], '#') : null;
        $position   = is_array($positions[0]) && isset($positions[0][0]) ? $positions[0][0] : null;

        $i = 0;

        $filtered = [];

        foreach ($this->entities as $name => $entity) {
            if ($i === 0 && ($entityName === $name || $entityName === null) && ($position === ':first' || $position === ':highest' || $position === null)) {
                $filtered[] = $entity;
            }

            if ($position === ':any' && ($entityName === $name || $entityName === null)) {
                $filtered[] = $entity;
            }

            if ($i + 1 === $this->entities->count() && ($entityName === $name || $entityName === null) && ($position === ':last' || $position === ':lowest')) {
                $filtered[] = $entity;
            }

            $i++;
        }

        $this->filtered = $filtered;

        return $this;
    }
19895
public function getResultGenerator($entity, $filters = [])
    {
        $methodName = 'get' . ucfirst($entity) . 's';

        $i = 0;
        $gotAll = false;
        while ($gotAll === false) {
            $filters['offset'] = ($i * 100);

            $result = $this->$methodName($filters);
            if (! isset($result['success']) || ! isset($result['data']) || $result['success'] !== true) {
                throw new Exception("Invalid API response: " . json_encode($result));
            }

            if (count($result['data']) < 100) {
                $gotAll = true;
            }

            foreach ($result['data'] as $item) {
                yield $item;
            }

            $i++;
        }
    }
1001749
public function count(string $table, string $filter = '', array $params = []): int
    {
        $query = [
            'table' => $table,
            'fields' => 'COUNT(*)'
        ];
        
        if ($filter) {
            
            $query['filter'] = $filter;
            
            if ($params) {
                $query['params'] = $params;
            }
        }
        
        $this->qb($query);
        
        return $this->value();
    }
511569
public function all($filter)
    {
        $result = $this->toArray();

        // If the value is null return the default
        if(!empty($result))
        {
            // Handle magic quotes compatibility
            if (get_magic_quotes_gpc()) {
                $result = $this->_stripSlashes( $result );
            }

            // Filter the data
            if(!($filter instanceof FilterInterface)) {
                $filter = $this->getObject('filter.factory')->createChain($filter);
            }

            $result = $filter->sanitize($result);
        }

        return $result;
    }
527916
public static function getOrdersCount($filter = array())
    {
        $filter = Filter::create($filter);
        return self::getCount('/orders/count' . $filter->toQuery());
    }
697667
public function getAll($filter = null)
    {
        $filters = array('all', 'sales', 'purchase', 'inactive');
        if (!in_array($filter, $filters)) {
            $message = 'Unknown filter "' . $filter . '" for TaxRates';
            $message .= '; available filters: ' . implode(', ', $filters);
            throw new InvalidFilterException($message);
        }

        $rates = new ArrayObject;
        foreach ($this->connector->getAll(__NAMESPACE__) as $rate) {
            if (($filter == 'inactive' && $rate->active) || ($filter != 'inactive' && !$rate->active)) {
                continue;
            }
            if ($filter == 'sales' && $rate->taxRateType != TaxRate::RATE_TYPE_SALES) {
                continue;
            } elseif ($filter == 'purchase' && $rate->taxRateType != TaxRate::RATE_TYPE_PURCHASE) {
                continue;
            }
            $rates->append($rate);
        }
        return $rates;
    }
33073
protected function getFilterParams(array &$filters, $filter)
    {
        $fragments = preg_split('%;%', $filter, -1, PREG_SPLIT_NO_EMPTY);

        $name = array_shift($fragments);
        $params = [];

        foreach ($fragments as $param) {
            list($key, $value)  = explode('=', $param);
            $params[$key] = $value;
        }

        $filters[$name] = $params;
    }
1108730
static function get($filterName)
    {
        if (!self::has($filterName))
            throw new \Exception(sprintf(
                'Filter "%s" Not Found.',
                $filterName
            ));

        return self::$filters[$filterName];
    }
971168
public static function findFirst(Filter ...$filters)
    {
        $results = static::find(...$filters);

        if (sizeof($results) == 0) {
            throw new RecordNotFoundException(get_called_class(), 0);
        }

        return $results[0];
    }
1147491
public function getFilter($filter) {
        if ($this->hasFilter($filter)) {
            return $this->_filters[$filter];
        }

        throw new MissingFilterException(sprintf('Filter %s does not exist', $filter));
    }
442550
private function getParams($filter)
    {
        $params = [];
        if ($filter) {
            $filter = (string) $filter;
            $filter = strtolower($filter);
            if ($filter !== 'all') {
                $validate = ['completed', 'incomplete', 'late', 'upcoming'];
                if (!in_array($filter, $validate)) {
                    throw new Exception('Invalid value for param filter');
                }
                $params['find'] = $filter;
            }
        }
        return $params;
    }
506883
public function getAll($classname, $filter = null, AbstractModel $parent = null)
    {
        $filterUrl = '';
        if (!is_null($filter)) {
            if (
                isset($this->filters[$classname]) &&
                in_array($filter, $this->filters[$classname])) {

                $filterUrl = '/filter/' . $filter;
            } elseif (
                isset($this->filters[$classname]) &&
                preg_match('/^[0-9]+$/D', $filter)) {

                $filterUrl = '/filter/' . $filter;
            } else {
                $message = 'Unknown filter "' . $filter . '" for ' . $classname;
                if (isset($this->filters[$classname])) {
                    $message .= '; available filters: ' . implode(', ', $this->filters[$classname]);
                }
                throw new InvalidFilterException($message);
            }
        }

        $response = $this->request($this->buildUrl(new $classname(), $parent, $filterUrl), 'GET');
        return $this->mapper->mapFromStorage($response);
    }
4190
public function distinct($fieldName, array $filter = [], array $options = [])
    {
        if (!is_string($fieldName)) {
            throw new InvalidArgumentException('$fieldName must be a string.');
        }

        if (!$fieldName) {
            throw new InvalidArgumentException('$fieldName cannot be empty.');
        }

        $command = ['distinct' => $this->collectionName, 'key' => $fieldName];
        if ($filter) {
            $command['query'] = (object) $filter;
        }
        $options['typeMap'] = [];

        $cursor = $this->executeCommand($command, $options);

        $result = $cursor->current();
        if (!isset($result->values)) {
            throw new UnexpectedResultException(
                'Command "distinct" did not return expected "values" array.'
            );
        }

        return $result->values;
    }
1223784
public function getAll(array $filters = null)
    {
        $response = $this->mailjet->get(Resources::$Template,
            ['filters' => $filters]);
        if (!$response->success()) {
            $this->throwError("TemplateService :getAll() failed", $response);
        }

        return $response->getData();
    }
267231
function select($fields,$filter=NULL,array $options=NULL,$ttl=0) {
		list($sql,$args)=$this->stringify($fields,$filter,$options);
		$result=$this->db->exec($sql,$args,$ttl);
		$out=[];
		foreach ($result as &$row) {
			foreach ($row as $field=>&$val) {
				if (array_key_exists($field,$this->fields)) {
					if (!is_null($val) || !$this->fields[$field]['nullable'])
						$val=$this->db->value(
							$this->fields[$field]['pdo_type'],$val);
				}
				unset($val);
			}
			$out[]=$this->factory($row);
			unset($row);
		}
		return $out;
	}