Get rows matching parameters

@param array  $parameters The parameters.
@param string $field      The field.
@param string $order      The order.
@return \Illuminate\Database\Eloquent\Collection
437665
public function where(array $parameters, string $field = null, string $order = null)
    {
        $key = "";
        foreach ($parameters as $k => $v) {
            $key .= $k . "_" . $v . "_";
        }
        if ($field) {
            $key .= $field;
        }
        if ($order) {
            $key .= $order;
        }
        return $this->cache->tags($this->getModel())->remember($key, 60, function () use ($parameters, $field, $order) {
            return $this->repository->where($parameters, $field, $order);
        });
    }
1309665
public static function lists($field, $filters = null)
    {
        $model = new static;

        $query = static::query(null, $model)->where($filters);

        $list = [];

        if (is_string($field)) {
            $keyField = $model->getPrimaryKey();
            $valueField = $field;

            $query = $query->select([$keyField, $valueField]);
            if (in_array('display_order', $model->getFields(), true)) {
                return $query->orderBy(['display_order' => SORT_DESC, $keyField => SORT_ASC])->fetch(true);
            } else {
                return $query->orderBy($keyField)->fetch(true);
            }
        } else {
            $keyField = key($field);
            $valueField = current($field);
            /** @noinspection ForeachSourceInspection */
            foreach ($query->select([$keyField, $valueField])->fetch(true) as $v) {
                $key = $v[$keyField];
                $value = $v[$valueField];

                if (!isset($list[$key])) {
                    $list[$key] = $value;
                } elseif (is_array($list[$key])) {
                    $list[$key][] = $value;
                } else {
                    $list[$key] = [$list[$key], $value];
                }
            }

            return $list;
        }
    }
31472
public function get(
        $where = null,
        $order = null,
        $limit = null,
        $offset = null,
        $columns = null,
        $group = null,
        $having = null
    ) {
        $result = parent::get($where, $order, $limit, $offset, $columns, $group, $having);
        return $result;
    }
791180
public function findAll($executeQuery = true, $orderedBy = 'id', $order = null)
    {
        if (!$executeQuery) {
            $dql = "
                SELECT u, pws, g, r, rws
                FROM Claroline\CoreBundle\Entity\User u
                LEFT JOIN u.personalWorkspace pws
                LEFT JOIN u.groups g
                LEFT JOIN u.roles r
                LEFT JOIN r.workspace rws
                WHERE u.isRemoved = false
                ORDER BY u.{$orderedBy} {$order}
            ";

            return $this->_em->createQuery($dql);
        }

        return parent::findAll();
    }
456469
public function orderBy($fields, string $direction = 'ASC'): IQueryBuilderHandler
    {
        if (\is_array($fields) === false) {
            $fields = [$fields];
        }

        foreach ((array)$fields as $key => $value) {
            $field = $key;
            $type = $value;

            if (\is_int($key) === true) {
                $field = $value;
                $type = $direction;
            }

            if (($field instanceof Raw) === false) {
                $field = $this->addTablePrefix($field);
            }

            $this->statements['orderBys'][] = compact('field', 'type');
        }

        return $this;
    }
1123848
public static function sortRecord($records, $field, $order=true)
    {
        $new_array = array();
        $sortable_array = array();

        if (count($records) > 0) {
            foreach ($records as $k => $v) {
                if (is_array($v)) {
                    foreach ($v as $k2 => $v2) {
                        if ($k2 == $field) {
                            $sortable_array[$k] = $v2;
                        }
                    }
                } else {
                    $sortable_array[$k] = $v;
                }
            }

            switch ($order) {
                case true:
                    asort($sortable_array);
                break;
                case false:
                    arsort($sortable_array);
                break;
            }

            foreach ($sortable_array as $k => $v) {
                $new_array[$k] = $records[$k];
            }
        }

        return $new_array;
    }
1332294
public function apply($query, array $parameters = [])
    {
        $info = $this->getModelInformation($query->getModel());

        $column = $info && $info->list->active_column ?: 'active';

        return $query->where($column, true);
    }
206771
public function byNestedField(
        string $field,
        string $order,
        string $mode = self::MODE_AVG
    ): SortBy {
        $this->sortsBy[] = [
            'type' => self::TYPE_NESTED,
            'mode' => $mode,
            'field' => "indexed_metadata.$field",
            'order' => $order,
        ];

        return $this;
    }
200541
private function prepareSelectQueryFromArguments($table_name, $fields, $conditions = null, $order_by_fields = null)
    {
        if (empty($table_name)) {
            throw new InvalidArgumentException('Table name is required');
        }

        $escaped_field_names = empty($fields) ? '*' : implode(',', array_map(function ($field_name) {
            return $this->escapeFieldName($field_name);
        }, (array) $fields));

        if ($conditions) {
            $where = 'WHERE ' . $this->prepareConditions($conditions);
        } else {
            $where = '';
        }

        $escaped_order_by_field_names = '';

        if (!empty($order_by_fields)) {
            $escaped_order_by_field_names = implode(',', array_map(function ($field_name) {
                return $this->escapeFieldName($field_name);
            }, (array) $order_by_fields));
        }

        $order_by = $escaped_order_by_field_names ? "ORDER BY $escaped_order_by_field_names" : '';

        return trim("SELECT $escaped_field_names FROM {$this->escapeTableName($table_name)} $where $order_by");
    }
1116927
protected function toSql($fields=null) : QueryBuilder
	{
		$queryBuilder = $this->queryBuilder()
		->select($fields)
		->from($this->table);

		$orderBy = [];

		if (isset(Model::$findOptions['asc'])) {
			$orderBy[] = Model::$findOptions['asc'] . ' ASC';
		}

		if (isset(Model::$findOptions['desc'])) {
			$orderBy[] = Model::$findOptions['desc'] . ' DESC';
		}

		if (!empty($orderBy)) {
			$queryBuilder->orderBy($orderBy);
		}

		if (isset(Model::$findOptions['limit'])) {
			$limit = Model::$findOptions['limit'];

			if (is_array($limit) && count($limit) > 1) {
				$queryBuilder->limit($limit[0], $limit[1]);
			}else{
				$queryBuilder->limit($limit);
			}
		}

		return $queryBuilder;
	}
422786
public function fieldSelect($table, $fields, $where, $orderBy = null)
    {
        $table = $this->getTableName($table);

        $query = "SELECT ";

        if (substr($this->mode, 0, 5) === "mssql") {
            $query .= "TOP 1 ";
        }

        $query .= $this->selectFields($fields);

        $query .= " FROM " . $table . " ";

        $params = null;
        if ($where !== self::NO_WHERE_CLAUSE) {
            $query .= "WHERE " . $this->where($where, $params);
        }

        if ($orderBy) {
            $query .= $this->orderBy($orderBy) . " ";
        }

        switch ($this->mode) {

            case "mysql":
            case "postgres":
            case "redshift":
            case "sqlite":
                $query .= "LIMIT 1";
                break;

            case "odbc":
                $query .= "FETCH FIRST 1 ROW ONLY";
                break;
        }

        return $this->query($query, $params)->fetch();
    }
534380
public function updateOrder($parameters = [])
    {
        $response = $this->client->put('transactions/orders/' . $parameters['transaction_id'], [
            'json' => $parameters,
        ]);
        return json_decode($response->getBody())->order;
    }
281736
public function orderByPagination($field, $order, $value)
    {
        return $this->getModel()->orderBy($field, $order)->paginate($value);
    }
685996
public function select(
        $table,
        $conditions = null,
        $fields = null,
        $order = null,
        $limit = null,
        $offset = null
    )
    {
        if (is_null($fields)) {
            $fields = "*";
        }

        $queryString = "SELECT {$fields} FROM {$table} ";

        if (!is_null($conditions)) {
            $queryString .= "WHERE {$conditions} ";
        }

        if (!is_null($order)) {
            $queryString .= "ORDER BY {$order} ";
        }

        if (!is_null($limit)) {
            $queryString .= "LIMIT {$limit} ";
        }

        if (!is_null($offset) && !is_null($limit)) {
            $queryString .= "OFFSET {$offset} ";
        }


        $queryString .= ";";

        $this->query($queryString);

        return $this->countRows();
    }
968148
public function order($field) {
        $order = [];
        if (is_array($field)) {
            foreach ($field as $key => $value) {
                $order[] = $key . ' ' . $value;
            }
        } else {
            $order = func_get_args();
        }
        $order = implode(',', $order);
        $this->order = !empty($order) ? ' ORDER BY ' . $order : '';
        return $this;
    }
815905
private function parseRuleParameters($field, $parameters)
    {
        // Make sure parameters is an array
        $parameters = (strpos($parameters, ',') > 0) ? explode(',', $parameters) : [$parameters];

        // Process each parameter
        foreach ($parameters as $key => $parameter)
        {
            // Replace ~table and ~field if they exist
            $parameter = str_ireplace(['~table', '~field'], [$this->getTable(), $field], $parameter);

            // Replace with attribute
            if (strpos($parameter, '~') !== false) $parameter = $this->{str_replace('~', '', $parameter)};
        }

        return $parameters;
    }
1300204
public function execute($query, $parameters = [])
    {
        $statement = $this->link->prepare($query);
        $statement->execute($parameters);
        return $statement->rowCount();
    }