V
V
Victor Umansky2017-09-11 16:04:04
C++ / C#
Victor Umansky, 2017-09-11 16:04:04

How to filter the value correctly?

Hello everyone, how to filter the value of what is on the screen.
there is a ProductSeeds table

id | ... | ... | ripeness_group <-- тут integer значения хранятся виде 180, 200 или 300, 500
id =>
...
ripeness_group => 180
---
id =>
...
ripeness_group => 200
и так далее

there is also a ProductSeedsSearch search model, but I don't understand how to do it yet
spoiler
<?php

namespace common\models;

use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use yii\data\Sort;
use yii\helpers\VarDumper;

/**
 * ProductSeedsSearch represents the model behind the search form about `common\models\ProductSeeds`.
 */
class ProductSeedsSearch extends ProductSeeds
{
    public $sort;
    public $category_title;

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['id', 'status', 'new', 'hit', 'sale', 'stock', 'top_sales', 'top_ten', 'category_id', 'quantity', 'img_id', 'gallery_id', 'brand_id', 'ripeness_group', 'country_id', 'rateNum', 'availability', 'created_at', 'updated_at'], 'integer'],
            [['title', 'content', 'vendor_code', 'seo_keywords', 'seo_description', 'category_title', 'sort'], 'safe'],
            //[['old_price', 'price'], 'number'],
        ];
    }

    /**
     * @inheritdoc
     */
    public function scenarios()
    {
        // bypass scenarios() implementation in the parent class
        return Model::scenarios();
    }

    /**
     * Creates data provider instance with search query applied
     *
     * @param array $params
     *
     * @return ActiveDataProvider
     */
    public function search($params)
    {
//        $query = ProductSeeds::find();

        // add conditions that should always apply here

        $id = Yii::$app->request->get('id');

        $query = ProductSeeds::find()->joinWith('category')->where(['category_id' => $id]);
        $dataProvider = new ActiveDataProvider([
            'query' => $query,
            'pagination' => [
                'pageSize' => 10,
            ],
        ]);
        $this->load($params);

        if (!$this->validate()) {
            return $dataProvider;
        }

        // grid filtering conditions
        $query->andFilterWhere([
            'brand_id' => $this->brand_id,
            'country_id' => $this->country_id,
            'ripeness_group' => $this->ripeness_group,
        ]);




        $query->andFilterWhere([
            'and',
            ['>=', 'price', Yii::$app->request->get('min_zena')],
            ['<=', 'price', Yii::$app->request->get('max_zena')]
        ]);


//        if ($this->price) {
//            $range = explode(',', $this->price);
//
//            $query->andFilterWhere([
//                'and',
//                ['>=', 'price', $range[0]],
//                ['<=', 'price', $range[1]]
//            ]);
//        }

        return $dataProvider;
    }
}
DmBZ6aqcNPxpDm.png

Answer the question

In order to leave comments, you need to log in

[[+comments_count]] answer(s)
D
Danil Shekhovtsov, 2020-08-16
@Dzmitryj_Black

There are two options: open in dotPeek, if the file has a CLR header, then it will allow you to see the classes and structure of the file, then decompile the methods. If it displays "dll not supported" or "exe not supported", then this means that there are no classes and program structure there, only exported functions and subroutines (internal functions, procedures), there are no methods, i.e. the paradigm of procedural programming is used (x86 is a procedural language, like any other machine language, respectively decompiled C - too, OOP is not here and is not expected, keep in mind). Here you already need to use a machine code decompiler, for example Ghidra; Hexrays is outdated, but you can also try it as an option. Then you compile and build the extracted C code, one function after another, correcting errors, which the decompiler can allow. In the case of C#, if there was CIL, you would have classes, fields, and methods. If mixed dll/exe technology is used, then combine dotPeek and Ghidra.

2
20ivs, 2019-05-24
@20ivs

if it were possible to simply take and decompile the desired program, then we would live in a different world, without piracy and copywriting.

A
Artem @Jump, 2019-05-24
curated by the

Is there a way to translate the installed program -> si?
No.
Decompilation is reading machine codes - in fact, manual work.

B
BasiC2k, 2019-05-24
@BasiC2k

Decompiling .NET programs is a simple matter. Try using dotPeek. After decompilation, you will need to understand the structure of the program and translate everything into the language you need. It's already handmade.

M
Maxim Timofeev, 2017-09-11
@Uman

And how did it happen that there is no ripeness_group in the search model? You need to add it to rule. And there it already depends where and how you sort. The gridView will be automatic.

M
Maxim Fedorov, 2017-09-12
@qonand

1. Declare the min_ripeness and max_repiness properties in the model
2. Using JS, add the values ​​of these properties to the filtering request sent by pressing the "OK" button
3. Filter the data using query->andFilterWhere(['between', 'ripeness_group', $ this->min_ripeness, $this->max_ripeness]);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question