Search and filter records

@since 1.x.x
@deprecated 2.0.0

@param null $orderby
@param int  $rows_per_page
@param null $where
@param null $sql

@return
439881
public function findRecords( $orderby = null, $rows_per_page = 15, $where = null, $sql = null ) {

		if ( Pod::$deprecated_notice ) {
			pods_deprecated( 'Pods::findRecords', '2.0', 'Pods::find' );
		}

		$find = array(
			' p.created',
			'`p`.`created`',
			'`p`.created',
			' p.`created`',
			' p.modified',
			'`p`.`modified`',
			'`p`.modified',
			' p.`modified`',
			' p.id',
			'`p`.`id`',
			'`p`.id',
			' p.`id`',
			' p.pod_id',
			'`p`.`pod_id`',
			'`p`.pod_id',
			' p.`pod_id`',
		);

		$replace = array(
			' t.created',
			'`t`.`created`',
			'`t`.created',
			' t.`created`',
			' t.modified',
			'`t`.`modified`',
			'`t`.modified',
			' t.`modified`',
			' t.id',
			'`t`.`id`',
			'`t`.id',
			' t.`id`',
			' t.id',
			'`t`.`id`',
			'`t`.id',
			' t.`id`',
		);

		$params = array(
			'where'               => $where,
			'orderby'             => "`t`.`{$this->obj->data->field_id}` DESC",
			'limit'               => (int) $rows_per_page,
			'page'                => $this->obj->page,
			'search'              => $this->obj->search,
			'search_across'       => true,
			'search_across_picks' => false,
			'sql'                 => $sql,
		);

		if ( is_array( $orderby ) ) {
			$params = array_merge( $params, $orderby );
		} elseif ( ! empty( $orderby ) ) {
			$params['orderby'] = $orderby;
		}

		$params['where']   = trim( str_replace( $find, $replace, ' ' . $params['where'] ) );
		$params['orderby'] = trim( str_replace( $find, $replace, ' ' . $params['orderby'] ) );

		$params = (object) $params;

		$this->obj->limit  = $params->limit;
		$this->obj->page   = $params->page;
		$this->obj->search = $params->search;

		return $this->obj->find( $params );
	}
869852
public function findOneBy(array $criteria, ?array $orderBy = null)
    {
        $criteria = $this->mapCriteriaSetUuidsToStrings($criteria);
        $entity   = $this->entityRepository->findOneBy($criteria, $orderBy);
        if (null === $entity) {
            return null;
        }
        if ($entity instanceof EntityInterface) {
            $this->initialiseEntity($entity);

            return $entity;
        }
    }
710938
public function get($where = array(), $order = array())
    {
        $this->connectToDB();
        $this->queryBuilder->table($this->view());
        //where
        $this->where($where);
        //order
        foreach($order as $field => $direction) {
            $this->queryBuilder->orderBy($field, $direction);
        }
        $records = $this->queryBuilder->get();
        return $records;
    }
864341
public function getUsers($orderBy = null)
    {
        $users = $this->createQueryBuilder('o')
            ->where('o.enabled = 1');

        $this->applySorting($users, $orderBy);

        return $users
            ->getQuery()
            ->getResult();
    }
932949
@Override
    public void orderRows(final OrderBy ob) {
        if (ob != null) {
            ob.setMetaData(getMetaData());
            ob.setParser(parser);
            Collections.sort(rows, ob);
            goTop();
        }
    }
391723
protected function createPaginatedQueryBuilder(array $criteria = [], $indexBy = null, array $orderBy = null)
    {
        $qb = new PaginatedQueryBuilder($this->_em);
        $qb->from($this->_entityName, $this->getEntityAlias(), $indexBy);

        $this->processCriteria($qb, $criteria);

        return $qb;
    }
736823
public function each($callable, $where = null, $orderby = null, $onpage = null, $page = null)
  {
    $q = $this->getManager()
      ->getQueryBuilder()
      ->select($this->getTable())
      ->where($where)
      ->orderby($orderby)
      ->page($page, $onpage);

    $st = $this->getManager()->query($q);

    while($obj = $this->fetchObject($st)) {
      call_user_func_array($callable, array($obj));
    }

    return $this;
  }
1161481
public function load(array $criteria, array $orderBy = null)
    {
        $stmt = $this->getMatchCypher($criteria, $orderBy);
        $result = $this->_em->getDatabaseDriver()->run($stmt->text(), $stmt->parameters());

        if ($result->size() > 1) {
            throw new \LogicException(sprintf('Expected only 1 record, got %d', $result->size()));
        }

        $hydrator = $this->_em->getEntityHydrator($this->_className);
        $entities = $hydrator->hydrateAll($result);

        return count($entities) === 1 ? $entities[0] : null;
    }
405702
public SqlBuilder orderBy(final List<Order> orders) {
    if (null != orders) {
      this.orders.addAll(orders);
    }
    return this;
  }
78694
public function fetchRow(array $where = null, array $column = null, array $order = null)
    {
        $qp = $this->_fetch($where, $column, $order);

        $row = $this->_fetchRow($qp['query'], $qp['params']);
        $className = $this->_rowClass;
        $class = new $className($this);

        if (!$row) {
            return false;
        }

        $class->setData($row);

        return $class;
    }
457655
public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
    {
        $this->throwBadMethodException('findBy');
    }
1192744
public static function all($perPage = -1, $orderby = 'menu_order', $order = 'ASC')
    {
        $order = strtoupper($order);

        $args = [
            'posts_per_page' => $perPage,
            'orderby'       => $orderby,
            'order'         => $order,
        ];

        return static::query($args);
    }
705577
public function select($fields = null, $where = null, $orderBy = null, $limit = null): Statement
    {
        $this->operation = 'select';
        return $this->setSelectArgument($fields, $where, $orderBy, $limit);
    }
601826
public function row($fields = null, $where = null, $orderBy = null)
    {
        // 查询数据
        $row = parent::row($fields, $where, $orderBy);

        // 如果没有查到
        if (!$row) {
            $row = [];
        }
        // 构造 为行对象
        return new Row($this->tableName, $row);
    }
213586
protected function applyOrderBy(array $data, $orderBy)
    {
        if (!empty($orderBy)) {
            ArrayHelper::multisort($data, array_keys($orderBy), array_values($orderBy));
        }

        return $data;
    }
963236
public function select($cols = null, $where = true, $order = null, $limit = null)
    {
        if ($this->map) {
            $cols = $this->map->cols($cols);
            $where = $this->map->where($where);
            $order = $this->map->order($order);
        }
        if ($cols === null) {
            $cols = true;
        }
        if ($this->fake) {
            $result = $this->fake->select($cols, $where, $order, $limit);
            if ($this->map) {
                return new ArrFetcher($this->map->assoc($result));
            }
            return $result;
        }
        $pattern = 'SELECT ?cols FROM ?t WHERE ?w';
        $data = array($cols, $this->name, $where);
        if ($order !== null) {
            $pattern .= ' ORDER BY ?o';
            $data[] = $order;
        }
        if ($limit !== null) {
            if (is_array($limit)) {
                $offset = isset($limit[1]) ? $limit[1] : 0;
                $limit = $limit[0];
            } else {
                $offset = 0;
            }
            $pattern .= ' LIMIT ?i,?i';
            $data[] = $offset;
            $data[] = $limit;
        }
        $fetcher = $this->db->query($pattern, $data);
        if ($this->map) {
            $data = $fetcher->assoc();
            $data = $this->map->assoc($data);
            $fetcher = new ArrFetcher($data);
        }
        return $fetcher;
    }
1298382
function get(tableName, fieldNames, where, orderBy) {
    if (orderBy && !checkOrderBy(orderBy)) {
      throw new Error('Invalid arg: orderBy');
    }
    if (!db) {
      throw new Error('Not connected');
    }
    let sql = `SELECT ${fieldNames.join(',')} FROM ${tableName}`;
    if (where) {
      sql += ` WHERE ${where}`;
    }
    if (orderBy) {
      sql += ` ORDER BY ${orderBy.join(',')}`;
    }
    return new Promise(((resolve, reject) => {
      db.get(sql, [], (error, row) => {
        if (error) {
          reject(error);
        } else {
          resolve(row);
        }
      });
    }));
  }